Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
1d034f0a
Commit
1d034f0a
authored
Jul 03, 2020
by
longpanda
Browse files
update
parent
0ddc76a3
Changes
33
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1000 additions
and
102 deletions
+1000
-102
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.c
...dk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.c
+61
-12
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.h
...dk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.h
+27
-1
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyDebug.c
...table201911/MdeModulePkg/Application/Ventoy/VentoyDebug.c
+82
-6
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyProtocol.c
...le201911/MdeModulePkg/Application/Ventoy/VentoyProtocol.c
+98
-3
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/VtoyUtil/Memhole.c
...-stable201911/MdeModulePkg/Application/VtoyUtil/Memhole.c
+179
-0
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/VtoyUtil/VtoyUtil.c
...stable201911/MdeModulePkg/Application/VtoyUtil/VtoyUtil.c
+135
-0
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/VtoyUtil/VtoyUtil.h
...stable201911/MdeModulePkg/Application/VtoyUtil/VtoyUtil.h
+61
-0
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/VtoyUtil/VtoyUtil.inf
...able201911/MdeModulePkg/Application/VtoyUtil/VtoyUtil.inf
+80
-0
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/MdeModulePkg.dsc
..._mod/edk2-edk2-stable201911/MdeModulePkg/MdeModulePkg.dsc
+1
-0
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
+68
-30
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
+13
-2
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c
+1
-1
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
+141
-27
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_windows.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_windows.c
+9
-11
GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h
GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h
+14
-4
GRUB2/MOD_SRC/grub-2.04/install.sh
GRUB2/MOD_SRC/grub-2.04/install.sh
+2
-2
INSTALL/grub/debug.cfg
INSTALL/grub/debug.cfg
+17
-1
INSTALL/ventoy_pack.sh
INSTALL/ventoy_pack.sh
+1
-1
IPXE/ipxe_mod_code/ipxe-3fe683e/src/arch/x86/core/ventoy_vdisk.c
...xe_mod_code/ipxe-3fe683e/src/arch/x86/core/ventoy_vdisk.c
+1
-1
IPXE/ipxe_mod_code/ipxe-3fe683e/src/include/ventoy.h
IPXE/ipxe_mod_code/ipxe-3fe683e/src/include/ventoy.h
+9
-0
No files found.
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.c
View file @
1d034f0a
...
...
@@ -52,6 +52,8 @@ static grub_env_get_pf grub_env_get = NULL;
ventoy_grub_param_file_replace
*
g_file_replace_list
=
NULL
;
ventoy_efi_file_replace
g_efi_file_replace
;
BOOLEAN
g_fix_windows_1st_cdrom_issue
=
FALSE
;
STATIC
BOOLEAN
g_hook_keyboard
=
FALSE
;
CHAR16
gFirstTryBootFile
[
256
]
=
{
0
};
...
...
@@ -493,6 +495,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
EFI_STATUS
Status
=
EFI_SUCCESS
;
ventoy_grub_param
*
pGrubParam
=
NULL
;
EFI_LOADED_IMAGE_PROTOCOL
*
pImageInfo
=
NULL
;
ventoy_chain_head
*
chain
=
NULL
;
Status
=
gBS
->
HandleProtocol
(
ImageHandle
,
&
gEfiLoadedImageProtocolGuid
,
(
VOID
**
)
&
pImageInfo
);
if
(
EFI_ERROR
(
Status
))
...
...
@@ -559,12 +562,15 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
);
pPos
=
StrStr
(
pCmdLine
,
L"mem:"
);
g_
chain
=
(
ventoy_chain_head
*
)
StrHexToUintn
(
pPos
+
4
);
chain
=
(
ventoy_chain_head
*
)
StrHexToUintn
(
pPos
+
4
);
pPos
=
StrStr
(
pPos
,
L"size:"
);
size
=
StrDecimalToUintn
(
pPos
+
5
);
debug
(
"memory addr:%p size:%lu"
,
g_chain
,
size
);
debug
(
"memory addr:%p size:%lu"
,
chain
,
size
);
g_chain
=
AllocatePool
(
size
);
CopyMem
(
g_chain
,
chain
,
size
);
if
(
StrStr
(
pCmdLine
,
L"memdisk"
))
{
...
...
@@ -583,12 +589,12 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
g_os_param_reserved
=
(
UINT8
*
)(
g_chain
->
os_param
.
vtoy_reserved
);
/* Workaround for Windows & ISO9660 */
if
(
g_os_param_reserved
[
2
]
==
1
&&
g_os_param_reserved
[
3
]
==
0
)
if
(
g_os_param_reserved
[
2
]
==
ventoy_chain_windows
&&
g_os_param_reserved
[
3
]
==
0
)
{
g_fixup_iso9660_secover_enable
=
TRUE
;
}
if
(
g_os_param_reserved
[
2
]
==
1
&&
g_os_param_reserved
[
4
]
!=
1
)
if
(
g_os_param_reserved
[
2
]
==
ventoy_chain_windows
&&
g_os_param_reserved
[
4
]
!=
1
)
{
g_hook_keyboard
=
TRUE
;
}
...
...
@@ -613,6 +619,17 @@ 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
]
||
ventoy_chain_wim
==
g_os_param_reserved
[
2
])
{
if
(
ventoy_is_cdrom_dp_exist
())
{
debug
(
"fixup the 1st cdrom influences when boot windows ..."
);
g_fix_windows_1st_cdrom_issue
=
TRUE
;
}
}
FreePool
(
pCmdLine
);
return
EFI_SUCCESS
;
}
...
...
@@ -636,6 +653,44 @@ EFI_STATUS EFIAPI ventoy_clean_env(VOID)
FreePool
((
VOID
*
)(
UINTN
)
g_chain
->
os_param
.
vtoy_img_location_addr
);
}
FreePool
(
g_chain
);
return
EFI_SUCCESS
;
}
STATIC
EFI_STATUS
ventoy_hook_start
(
VOID
)
{
/* don't add debug print in this function */
if
(
g_fix_windows_1st_cdrom_issue
)
{
ventoy_hook_1st_cdrom_start
();
}
/* let this the last */
if
(
g_hook_keyboard
)
{
ventoy_hook_keyboard_start
();
}
return
EFI_SUCCESS
;
}
STATIC
EFI_STATUS
ventoy_hook_stop
(
VOID
)
{
/* don't add debug print in this function */
if
(
g_fix_windows_1st_cdrom_issue
)
{
ventoy_hook_1st_cdrom_stop
();
}
/* let this the last */
if
(
g_hook_keyboard
)
{
ventoy_hook_keyboard_stop
();
}
return
EFI_SUCCESS
;
}
...
...
@@ -725,17 +780,11 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
pFile
->
OpenVolume
=
ventoy_wrapper_open_volume
;
}
if
(
g_hook_keyboard
)
{
ventoy_hook_keyboard_start
();
}
ventoy_hook_start
();
/* can't add debug print here */
//ventoy_wrapper_system();
Status
=
gBS
->
StartImage
(
Image
,
NULL
,
NULL
);
if
(
g_hook_keyboard
)
{
ventoy_hook_keyboard_stop
();
}
ventoy_hook_stop
();
if
(
EFI_ERROR
(
Status
))
{
...
...
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.h
View file @
1d034f0a
...
...
@@ -25,6 +25,15 @@
#define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
typedef
enum
ventoy_chain_type
{
ventoy_chain_linux
=
0
,
/* 0: linux */
ventoy_chain_windows
,
/* 1: windows */
ventoy_chain_wim
,
/* 2: wim */
ventoy_chain_max
}
ventoy_chain_type
;
#pragma pack(1)
typedef
struct
ventoy_guid
...
...
@@ -216,6 +225,7 @@ if (gDebugPrint) \
}
typedef
const
char
*
(
*
grub_env_get_pf
)(
const
char
*
name
);
typedef
int
(
*
grub_env_printf_pf
)(
const
char
*
fmt
,
...);
#pragma pack(1)
...
...
@@ -242,8 +252,8 @@ typedef struct ventoy_grub_param_file_replace
typedef
struct
ventoy_grub_param
{
grub_env_get_pf
grub_env_get
;
ventoy_grub_param_file_replace
file_replace
;
grub_env_printf_pf
grub_env_printf
;
}
ventoy_grub_param
;
typedef
struct
ventoy_ram_disk
...
...
@@ -279,6 +289,18 @@ typedef struct ventoy_system_wrapper
EFI_OPEN_PROTOCOL
NewOpenProtocol
;
EFI_OPEN_PROTOCOL
OriOpenProtocol
;
EFI_LOCATE_HANDLE_BUFFER
NewLocateHandleBuffer
;
EFI_LOCATE_HANDLE_BUFFER
OriLocateHandleBuffer
;
EFI_PROTOCOLS_PER_HANDLE
NewProtocolsPerHandle
;
EFI_PROTOCOLS_PER_HANDLE
OriProtocolsPerHandle
;
EFI_LOCATE_HANDLE
NewLocateHandle
;
EFI_LOCATE_HANDLE
OriLocateHandle
;
EFI_LOCATE_DEVICE_PATH
NewLocateDevicePath
;
EFI_LOCATE_DEVICE_PATH
OriLocateDevicePath
;
}
ventoy_system_wrapper
;
#define ventoy_wrapper(bs, wrapper, func, newfunc) \
...
...
@@ -317,6 +339,7 @@ extern UINTN g_iso_buf_size;
extern
ventoy_grub_param_file_replace
*
g_file_replace_list
;
extern
BOOLEAN
g_fixup_iso9660_secover_enable
;
extern
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*
g_con_simple_input_ex
;
extern
BOOLEAN
g_fix_windows_1st_cdrom_issue
;
EFI_STATUS
EFIAPI
ventoy_wrapper_open_volume
(
...
...
@@ -327,6 +350,9 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
EFI_STATUS
EFIAPI
ventoy_wrapper_push_openvolume
(
IN
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME
OpenVolume
);
EFI_STATUS
ventoy_hook_keyboard_start
(
VOID
);
EFI_STATUS
ventoy_hook_keyboard_stop
(
VOID
);
BOOLEAN
ventoy_is_cdrom_dp_exist
(
VOID
);
EFI_STATUS
ventoy_hook_1st_cdrom_start
(
VOID
);
EFI_STATUS
ventoy_hook_1st_cdrom_stop
(
VOID
);
#endif
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyDebug.c
View file @
1d034f0a
...
...
@@ -36,9 +36,9 @@
#include <Protocol/SimpleFileSystem.h>
#include <Ventoy.h>
#define PROCOTOL_SLEEP_SECONDS 0
#define PROCOTOL_SLEEP_
M
SECONDS 0
#define debug_sleep() if (PROCOTOL_SLEEP_SECONDS)
sleep(
PROCOTOL_SLEEP_SECONDS)
#define debug_sleep() if (PROCOTOL_SLEEP_
M
SECONDS)
gBS->Stall(1000 *
PROCOTOL_SLEEP_
M
SECONDS)
STATIC
ventoy_system_wrapper
g_system_wrapper
;
...
...
@@ -126,7 +126,7 @@ STATIC EFI_STATUS EFIAPI ventoy_open_protocol
IN
UINT32
Attributes
)
{
debug
(
"ventoy_open_protocol:
%a"
,
ventoy_get_guid_name
(
Protocol
));
debug_sleep
();
debug
(
"ventoy_open_protocol:
<%p> %a"
,
Handle
,
ventoy_get_guid_name
(
Protocol
));
debug_sleep
();
return
g_system_wrapper
.
OriOpenProtocol
(
Handle
,
Protocol
,
Interface
,
AgentHandle
,
ControllerHandle
,
Attributes
);
}
...
...
@@ -141,11 +141,87 @@ STATIC EFI_STATUS EFIAPI ventoy_locate_protocol
return
g_system_wrapper
.
OriLocateProtocol
(
Protocol
,
Registration
,
Interface
);
}
STATIC
EFI_STATUS
EFIAPI
ventoy_locate_handle_buffer
(
IN
EFI_LOCATE_SEARCH_TYPE
SearchType
,
IN
EFI_GUID
*
Protocol
,
OPTIONAL
IN
VOID
*
SearchKey
,
OPTIONAL
IN
OUT
UINTN
*
NoHandles
,
OUT
EFI_HANDLE
**
Buffer
)
{
debug
(
"ventoy_locate_handle_buffer:%a"
,
ventoy_get_guid_name
(
Protocol
));
debug_sleep
();
return
g_system_wrapper
.
OriLocateHandleBuffer
(
SearchType
,
Protocol
,
SearchKey
,
NoHandles
,
Buffer
);
}
STATIC
EFI_STATUS
EFIAPI
ventoy_protocol_per_handle
(
IN
EFI_HANDLE
Handle
,
OUT
EFI_GUID
***
ProtocolBuffer
,
OUT
UINTN
*
ProtocolBufferCount
)
{
debug
(
"ventoy_protocol_per_handle:%p"
,
Handle
);
debug_sleep
();
return
g_system_wrapper
.
OriProtocolsPerHandle
(
Handle
,
ProtocolBuffer
,
ProtocolBufferCount
);
}
EFI_STATUS
EFIAPI
ventoy_locate_handle
(
IN
EFI_LOCATE_SEARCH_TYPE
SearchType
,
IN
EFI_GUID
*
Protocol
,
OPTIONAL
IN
VOID
*
SearchKey
,
OPTIONAL
IN
OUT
UINTN
*
BufferSize
,
OUT
EFI_HANDLE
*
Buffer
)
{
UINTN
i
;
EFI_HANDLE
Handle
;
EFI_STATUS
Status
=
EFI_SUCCESS
;
debug
(
"ventoy_locate_handle: %d %a %p"
,
SearchType
,
ventoy_get_guid_name
(
Protocol
),
SearchKey
);
Status
=
g_system_wrapper
.
OriLocateHandle
(
SearchType
,
Protocol
,
SearchKey
,
BufferSize
,
Buffer
);
debug
(
"ventoy_locate_handle: %r Handle Count:%u"
,
Status
,
*
BufferSize
/
sizeof
(
EFI_HANDLE
));
if
(
EFI_SUCCESS
==
Status
)
{
for
(
i
=
0
;
i
<
*
BufferSize
/
sizeof
(
EFI_HANDLE
);
i
++
)
{
if
(
Buffer
[
i
]
==
gBlockData
.
Handle
)
{
Handle
=
Buffer
[
0
];
Buffer
[
0
]
=
Buffer
[
i
];
Buffer
[
i
]
=
Handle
;
debug
(
"####### Handle at %u"
,
i
);
break
;
}
}
}
debug_sleep
();
return
Status
;
}
STATIC
EFI_STATUS
EFIAPI
ventoy_locate_device_path
(
IN
EFI_GUID
*
Protocol
,
IN
OUT
EFI_DEVICE_PATH_PROTOCOL
**
DevicePath
,
OUT
EFI_HANDLE
*
Device
)
{
debug
(
"ventoy_locate_device_path:%a"
,
ventoy_get_guid_name
(
Protocol
));
debug_sleep
();
return
g_system_wrapper
.
OriLocateDevicePath
(
Protocol
,
DevicePath
,
Device
);
}
EFI_STATUS
EFIAPI
ventoy_wrapper_system
(
VOID
)
{
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
LocateProtocol
,
ventoy_locate_protocol
);
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
HandleProtocol
,
ventoy_handle_protocol
);
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
OpenProtocol
,
ventoy_open_protocol
);
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
LocateProtocol
,
ventoy_locate_protocol
);
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
HandleProtocol
,
ventoy_handle_protocol
);
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
OpenProtocol
,
ventoy_open_protocol
);
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
LocateHandleBuffer
,
ventoy_locate_handle_buffer
);
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
ProtocolsPerHandle
,
ventoy_protocol_per_handle
);
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
LocateHandle
,
ventoy_locate_handle
);
ventoy_wrapper
(
gBS
,
g_system_wrapper
,
LocateDevicePath
,
ventoy_locate_device_path
);
return
EFI_SUCCESS
;
}
...
...
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyProtocol.c
View file @
1d034f0a
...
...
@@ -65,6 +65,47 @@ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *g_con_simple_input_ex = NULL;
STATIC
EFI_INPUT_READ_KEY_EX
g_org_read_key_ex
=
NULL
;
STATIC
EFI_INPUT_READ_KEY
g_org_read_key
=
NULL
;
STATIC
EFI_LOCATE_HANDLE
g_org_locate_handle
=
NULL
;
BOOLEAN
ventoy_is_cdrom_dp_exist
(
VOID
)
{
UINTN
i
=
0
;
UINTN
Count
=
0
;
EFI_HANDLE
*
Handles
=
NULL
;
EFI_STATUS
Status
=
EFI_SUCCESS
;
EFI_DEVICE_PATH_PROTOCOL
*
DevicePath
=
NULL
;
Status
=
gBS
->
LocateHandleBuffer
(
ByProtocol
,
&
gEfiDevicePathProtocolGuid
,
NULL
,
&
Count
,
&
Handles
);
if
(
EFI_ERROR
(
Status
))
{
return
FALSE
;
}
for
(
i
=
0
;
i
<
Count
;
i
++
)
{
Status
=
gBS
->
HandleProtocol
(
Handles
[
i
],
&
gEfiDevicePathProtocolGuid
,
(
VOID
**
)
&
DevicePath
);
if
(
EFI_ERROR
(
Status
))
{
continue
;
}
while
(
!
IsDevicePathEnd
(
DevicePath
))
{
if
(
MEDIA_DEVICE_PATH
==
DevicePath
->
Type
&&
MEDIA_CDROM_DP
==
DevicePath
->
SubType
)
{
FreePool
(
Handles
);
return
TRUE
;
}
DevicePath
=
NextDevicePathNode
(
DevicePath
);
}
}
FreePool
(
Handles
);
return
FALSE
;
}
#if 0
/* Block IO procotol */
#endif
...
...
@@ -475,7 +516,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
if
(
i
<
Count
)
{
Status
=
gBS
->
ConnectController
(
ControllerHandle
,
DrvHandles
,
NULL
,
TRUE
);
debug
(
"
Connect partition driver:<%r>"
,
Status
);
debug
(
"
ventoy_connect_driver:<%s> <%r>"
,
DrvName
,
Status
);
goto
end
;
}
...
...
@@ -517,7 +558,7 @@ EFI_STATUS EFIAPI ventoy_connect_driver(IN EFI_HANDLE ControllerHandle, IN CONST
if
(
i
<
Count
)
{
Status
=
gBS
->
ConnectController
(
ControllerHandle
,
DrvHandles
,
NULL
,
TRUE
);
debug
(
"
Connect partition driver:<%r>"
,
Status
);
debug
(
"
ventoy_connect_driver:<%s> <%r>"
,
DrvName
,
Status
);
goto
end
;
}
...
...
@@ -535,6 +576,9 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
EFI_BLOCK_IO_PROTOCOL
*
pBlockIo
=
&
(
gBlockData
.
BlockIo
);
ventoy_fill_device_path
();
debug
(
"install block io protocol %p"
,
ImageHandle
);
ventoy_debug_pause
();
gBlockData
.
Media
.
BlockSize
=
2048
;
gBlockData
.
Media
.
LastBlock
=
ImgSize
/
2048
-
1
;
...
...
@@ -561,7 +605,6 @@ EFI_STATUS EFIAPI ventoy_install_blockio(IN EFI_HANDLE ImageHandle, IN UINT64 Im
Status
=
ventoy_connect_driver
(
gBlockData
.
Handle
,
L"Disk I/O Driver"
);
debug
(
"Connect disk IO driver %r"
,
Status
);
ventoy_debug_pause
();
Status
=
ventoy_connect_driver
(
gBlockData
.
Handle
,
L"Partition Driver"
);
debug
(
"Connect partition driver %r"
,
Status
);
...
...
@@ -916,3 +959,55 @@ EFI_STATUS ventoy_hook_keyboard_stop(VOID)
return
EFI_SUCCESS
;
}
#if 0
/* Fixup the 1st cdrom influnce for Windows boot */
#endif
STATIC
EFI_STATUS
EFIAPI
ventoy_wrapper_locate_handle
(
IN
EFI_LOCATE_SEARCH_TYPE
SearchType
,
IN
EFI_GUID
*
Protocol
,
OPTIONAL
IN
VOID
*
SearchKey
,
OPTIONAL
IN
OUT
UINTN
*
BufferSize
,
OUT
EFI_HANDLE
*
Buffer
)
{
UINTN
i
;
EFI_HANDLE
Handle
=
NULL
;
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
++
)
{
if
(
Buffer
[
i
]
==
gBlockData
.
Handle
)
{
Handle
=
Buffer
[
0
];
Buffer
[
0
]
=
Buffer
[
i
];
Buffer
[
i
]
=
Handle
;
break
;
}
}
}
return
Status
;
}
EFI_STATUS
ventoy_hook_1st_cdrom_start
(
VOID
)
{
g_org_locate_handle
=
gBS
->
LocateHandle
;
gBS
->
LocateHandle
=
ventoy_wrapper_locate_handle
;
return
EFI_SUCCESS
;
}
EFI_STATUS
ventoy_hook_1st_cdrom_stop
(
VOID
)
{
gBS
->
LocateHandle
=
g_org_locate_handle
;
g_org_locate_handle
=
NULL
;
return
EFI_SUCCESS
;
}
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/VtoyUtil/Memhole.c
0 → 100644
View file @
1d034f0a
/******************************************************************************
* Memhole.c
*
* Copyright (c) 2020, longpanda <admin@ventoy.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include <Uefi.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Protocol/LoadedImage.h>
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
#include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h>
#include <VtoyUtil.h>
STATIC
BOOLEAN
IsMemContiguous
(
IN
CONST
EFI_MEMORY_DESCRIPTOR
*
Prev
,
IN
CONST
EFI_MEMORY_DESCRIPTOR
*
Curr
,
IN
CONST
EFI_MEMORY_DESCRIPTOR
*
Next
)
{
UINTN
Addr1
=
0
;
UINTN
Addr2
=
0
;
if
(
Prev
==
NULL
||
Curr
==
NULL
||
Next
==
NULL
)
{
return
FALSE
;
}
if
(
Prev
->
Type
==
EfiBootServicesData
&&
Curr
->
Type
==
EfiConventionalMemory
&&
Next
->
Type
==
EfiBootServicesData
)
{
Addr1
=
Prev
->
PhysicalStart
+
MultU64x64
(
SIZE_4KB
,
Prev
->
NumberOfPages
);
Addr2
=
Curr
->
PhysicalStart
+
MultU64x64
(
SIZE_4KB
,
Curr
->
NumberOfPages
);
if
(
Addr1
==
Curr
->
PhysicalStart
&&
Addr2
==
Next
->
PhysicalStart
)
{
return
TRUE
;
}
}
return
FALSE
;
}
STATIC
EFI_MEMORY_DESCRIPTOR
*
GetMemDesc
(
OUT
UINTN
*
pSize
,
OUT
UINTN
*
pItemSize
,
OUT
UINTN
*
pDescCount
)
{
UINTN
Size
=
0
;
UINTN
MapKey
=
0
;
UINTN
ItemSize
=
0
;
UINTN
DescCount
=
0
;
UINT32
Version
=
0
;
EFI_STATUS
Status
=
EFI_SUCCESS
;
EFI_MEMORY_DESCRIPTOR
*
pDesc
=
NULL
;
EFI_MEMORY_DESCRIPTOR
*
Curr
=
NULL
;
Status
=
gBS
->
GetMemoryMap
(
&
Size
,
pDesc
,
&
MapKey
,
&
ItemSize
,
&
Version
);
if
(
EFI_BUFFER_TOO_SMALL
!=
Status
)
{
debug
(
"GetMemoryMap: %r"
,
Status
);
return
NULL
;
}
Size
+=
SIZE_1KB
;
pDesc
=
AllocatePool
(
Size
);
if
(
!
pDesc
)
{
debug
(
"AllocatePool: %lu failed"
,
Size
);
return
NULL
;
}
ZeroMem
(
pDesc
,
Size
);
Status
=
gBS
->
GetMemoryMap
(
&
Size
,
pDesc
,
&
MapKey
,
&
ItemSize
,
&
Version
);
if
(
EFI_ERROR
(
Status
))
{
debug
(
"GetMemoryMap: %r"
,
Status
);
FreePool
(
pDesc
);
return
NULL
;
}
Curr
=
pDesc
;
while
(
Curr
&&
Curr
<
(
EFI_MEMORY_DESCRIPTOR
*
)((
UINT8
*
)
pDesc
+
Size
))
{
DescCount
++
;
Curr
=
(
EFI_MEMORY_DESCRIPTOR
*
)((
UINT8
*
)
Curr
+
ItemSize
);
}
*
pSize
=
Size
;
*
pItemSize
=
ItemSize
;
*
pDescCount
=
DescCount
;
debug
(
"GetMemoryMap: ItemSize:%lu Count:%lu"
,
ItemSize
,
DescCount
);
return
pDesc
;
}
EFI_STATUS
FixWindowsMemhole
(
IN
EFI_HANDLE
ImageHandle
,
IN
CONST
CHAR16
*
CmdLine
)
{
UINTN
Size
=
0
;
UINTN
ItemSize
=
0
;
UINTN
DescCount
=
0
;
UINTN
TotalMem
=
0
;
EFI_STATUS
Status
=
EFI_SUCCESS
;
EFI_PHYSICAL_ADDRESS
AllocAddr
=
0
;
EFI_MEMORY_DESCRIPTOR
*
pDescs
=
NULL
;
EFI_MEMORY_DESCRIPTOR
*
Prev
=
NULL
;
EFI_MEMORY_DESCRIPTOR
*
Next
=
NULL
;
EFI_MEMORY_DESCRIPTOR
*
Curr
=
NULL
;
(
VOID
)
ImageHandle
;
(
VOID
)
CmdLine
;
pDescs
=
GetMemDesc
(
&
Size
,
&
ItemSize
,
&
DescCount
);
if
(
!
pDescs
)
{
return
EFI_NOT_FOUND
;
}
if
(
DescCount
<
500
)
{
FreePool
(
pDescs
);
Printf
(
"There is no need to fixup (%lu)
\n
"
,
DescCount
);
return
EFI_SUCCESS
;
}
Curr
=
pDescs
;
while
((
UINT8
*
)
Curr
<
(
UINT8
*
)
pDescs
+
Size
)
{
Next
=
(
EFI_MEMORY_DESCRIPTOR
*
)((
UINT8
*
)
Curr
+
ItemSize
);
if
(
IsMemContiguous
(
Prev
,
Curr
,
Next
))
{
AllocAddr
=
Curr
->
PhysicalStart
;
Status
=
gBS
->
AllocatePages
(
AllocateAddress
,
EfiBootServicesData
,
Curr
->
NumberOfPages
,
&
AllocAddr
);
if
(
EFI_SUCCESS
==
Status
)
{
TotalMem
+=
MultU64x64
(
SIZE_4KB
,
Curr
->
NumberOfPages
);
}
}
Prev
=
Curr
;
Curr
=
Next
;
}
Printf
(
"Fixup Windows mmap issue OK (%lu)
\n
"
,
TotalMem
);
return
EFI_SUCCESS
;
}
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/VtoyUtil/VtoyUtil.c
0 → 100644
View file @
1d034f0a
/******************************************************************************
* VtoyUtil.c
*
* Copyright (c) 2020, longpanda <admin@ventoy.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include <Uefi.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Protocol/LoadedImage.h>
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
#include <Protocol/BlockIo.h>
#include <Protocol/RamDisk.h>
#include <Protocol/SimpleFileSystem.h>
#include <VtoyUtil.h>
BOOLEAN
gVtoyDebugPrint
=
FALSE
;
STATIC
CONST
CHAR16
*
gCurFeature
=
NULL
;
STATIC
CHAR16
*
gCmdLine
=
NULL
;
STATIC
grub_env_printf_pf
g_env_printf
=
NULL
;
STATIC
VtoyUtilFeature
gFeatureList
[]
=
{
{
L"fix_windows_mmap"
,
FixWindowsMemhole
},
};
VOID
EFIAPI
VtoyUtilDebug
(
IN
CONST
CHAR8
*
Format
,
...)
{
VA_LIST
Marker
;
CHAR8
Buffer
[
512
];
VA_START
(
Marker
,
Format
);
AsciiVSPrint
(
Buffer
,
sizeof
(
Buffer
),
Format
,
Marker
);
VA_END
(
Marker
);
if
(
g_env_printf
)
{
g_env_printf
(
"%s"
,
Buffer
);
}
}
STATIC
EFI_STATUS
ParseCmdline
(
IN
EFI_HANDLE
ImageHandle
)
{
CHAR16
*
pPos
=
NULL
;
CHAR16
*
pCmdLine
=
NULL
;
EFI_STATUS
Status
=
EFI_SUCCESS
;
ventoy_grub_param
*
pGrubParam
=
NULL
;
EFI_LOADED_IMAGE_PROTOCOL
*
pImageInfo
=
NULL
;
Status
=
gBS
->
HandleProtocol
(
ImageHandle
,
&
gEfiLoadedImageProtocolGuid
,
(
VOID
**
)
&
pImageInfo
);
if
(
EFI_ERROR
(
Status
))
{
return
Status
;
}
pCmdLine
=
(
CHAR16
*
)
AllocatePool
(
pImageInfo
->
LoadOptionsSize
+
4
);
SetMem
(
pCmdLine
,
pImageInfo
->
LoadOptionsSize
+
4
,
0
);
CopyMem
(
pCmdLine
,
pImageInfo
->
LoadOptions
,
pImageInfo
->
LoadOptionsSize
);
if
(
StrStr
(
pCmdLine
,
L"debug"
))
{
gVtoyDebugPrint
=
TRUE
;
}
pPos
=
StrStr
(
pCmdLine
,
L"env_param="
);
if
(
!
pPos
)
{
return
EFI_INVALID_PARAMETER
;
}
pGrubParam
=
(
ventoy_grub_param
*
)
StrHexToUintn
(
pPos
+
StrLen
(
L"env_param="
));
g_env_printf
=
pGrubParam
->
grub_env_printf
;
pPos
=
StrStr
(
pCmdLine
,
L"feature="
);
if
(
!
pPos
)
{
return
EFI_INVALID_PARAMETER
;
}
gCurFeature
=
pPos
+
StrLen
(
L"feature="
);
gCmdLine
=
pCmdLine
;
return
EFI_SUCCESS
;
}
EFI_STATUS
EFIAPI
VtoyUtilEfiMain
(
IN
EFI_HANDLE
ImageHandle
,
IN
EFI_SYSTEM_TABLE
*
SystemTable
)
{
UINTN
i
;
UINTN
Len
;
ParseCmdline
(
ImageHandle
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
gFeatureList
);
i
++
)
{
Len
=
StrLen
(
gFeatureList
[
i
].
Cmd
);
if
(
StrnCmp
(
gFeatureList
[
i
].
Cmd
,
gCurFeature
,
Len
)
==
0
)
{
debug
(
"Find main proc <%s>"
,
gFeatureList
[
i
].
Cmd
);
gFeatureList
[
i
].
MainProc
(
ImageHandle
,
gCurFeature
+
Len
);
break
;
}
}
FreePool
(
gCmdLine
);
gCmdLine
=
NULL
;
return
EFI_SUCCESS
;
}
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/VtoyUtil/VtoyUtil.h
0 → 100644
View file @
1d034f0a
/******************************************************************************
* VtoyUtil.h
*
* Copyright (c) 2020, longpanda <admin@ventoy.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __VTOYUTIL_H__
#define __VTOYUTIL_H__
#pragma pack(1)
typedef
EFI_STATUS
(
*
VTOY_UTIL_PROC_PF
)(
IN
EFI_HANDLE
ImageHandle
,
IN
CONST
CHAR16
*
CmdLine
);
typedef
const
char
*
(
*
grub_env_get_pf
)(
const
char
*
name
);
typedef
int
(
*
grub_env_printf_pf
)(
const
char
*
fmt
,
...);
typedef
struct
ventoy_grub_param_file_replace
{
UINT32
magic
;
char
old_file_name
[
4
][
256
];
UINT32
old_file_cnt
;
UINT32
new_file_virtual_id
;
}
ventoy_grub_param_file_replace
;
typedef
struct
ventoy_grub_param
{
grub_env_get_pf
grub_env_get
;
ventoy_grub_param_file_replace
file_replace
;
grub_env_printf_pf
grub_env_printf
;
}
ventoy_grub_param
;
#pragma pack()
typedef
struct
VtoyUtilFeature
{
CONST
CHAR16
*
Cmd
;
VTOY_UTIL_PROC_PF
MainProc
;
}
VtoyUtilFeature
;
extern
BOOLEAN
gVtoyDebugPrint
;
VOID
EFIAPI
VtoyUtilDebug
(
IN
CONST
CHAR8
*
Format
,
...);
#define debug(expr, ...) if (gVtoyDebugPrint) VtoyUtilDebug("[VTOY] "expr"\n", ##__VA_ARGS__)
#define Printf VtoyUtilDebug
EFI_STATUS
FixWindowsMemhole
(
IN
EFI_HANDLE
ImageHandle
,
IN
CONST
CHAR16
*
CmdLine
);
#endif
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/VtoyUtil/VtoyUtil.inf
0 → 100644
View file @
1d034f0a
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = VtoyUtil
FILE_GUID = a43466a0-68c6-469d-ba4b-678bbe90bc47
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = VtoyUtilEfiMain
[Sources]
VtoyUtil.h
VtoyUtil.c
Memhole.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
ShellPkg/ShellPkg.dec
[LibraryClasses]
UefiApplicationEntryPoint
UefiLib
DebugLib
[Guids]
gShellVariableGuid
gEfiVirtualCdGuid
gEfiFileInfoGuid
[Protocols]
gEfiLoadedImageProtocolGuid
gEfiBlockIoProtocolGuid
gEfiDevicePathProtocolGuid
gEfiSimpleFileSystemProtocolGuid
gEfiRamDiskProtocolGuid
gEfiAbsolutePointerProtocolGuid
gEfiAcpiTableProtocolGuid
gEfiBlockIo2ProtocolGuid
gEfiBusSpecificDriverOverrideProtocolGuid
gEfiComponentNameProtocolGuid
gEfiComponentName2ProtocolGuid
gEfiDriverBindingProtocolGuid
gEfiDiskIoProtocolGuid
gEfiDiskIo2ProtocolGuid
gEfiGraphicsOutputProtocolGuid
gEfiHiiConfigAccessProtocolGuid
gEfiHiiFontProtocolGuid
gEfiLoadFileProtocolGuid
gEfiLoadFile2ProtocolGuid
gEfiLoadedImageProtocolGuid
gEfiLoadedImageDevicePathProtocolGuid
gEfiPciIoProtocolGuid
gEfiSerialIoProtocolGuid
gEfiSimpleTextInProtocolGuid
gEfiSimpleTextInputExProtocolGuid
gEfiSimpleTextOutProtocolGuid
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/MdeModulePkg.dsc
View file @
1d034f0a
...
...
@@ -204,6 +204,7 @@
[Components]
MdeModulePkg/Application/Ventoy/Ventoy.inf
MdeModulePkg/Application/VtoyUtil/VtoyUtil.inf
MdeModulePkg/Application/HelloWorld/HelloWorld.inf
MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.inf
MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.inf
...
...
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
View file @
1d034f0a
...
...
@@ -891,8 +891,8 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
*
((
img_info
**
)(
node
->
tail
))
=
img
;
g_ventoy_img_count
++
;
img
->
alias
=
ventoy_plugin_get_menu_alias
(
img
->
path
);
img
->
class
=
ventoy_plugin_get_menu_class
(
img
->
name
);
img
->
alias
=
ventoy_plugin_get_menu_alias
(
vtoy_alias_image_file
,
img
->
path
);
img
->
class
=
ventoy_plugin_get_menu_class
(
vtoy_class_image_file
,
img
->
name
);
if
(
!
img
->
class
)
{
img
->
class
=
g_menu_class
[
type
];
...
...
@@ -1029,7 +1029,9 @@ static img_iterator_node * ventoy_get_min_child(img_iterator_node *node)
static
int
ventoy_dynamic_tree_menu
(
img_iterator_node
*
node
)
{
int
offset
=
1
;
img_info
*
img
;
img_info
*
img
=
NULL
;
const
char
*
dir_class
=
NULL
;
const
char
*
dir_alias
=
NULL
;
img_iterator_node
*
child
=
NULL
;
if
(
node
->
isocnt
==
0
||
node
->
done
==
1
)
...
...
@@ -1055,9 +1057,25 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
else
{
node
->
dir
[
node
->
dirlen
-
1
]
=
0
;
vtoy_ssprintf
(
g_tree_script_buf
,
g_tree_script_pos
,
"submenu
\"
%-10s [%s]
\"
--class=
\"
vtoydir
\"
{
\n
"
,
"DIR"
,
node
->
dir
+
offset
);
dir_class
=
ventoy_plugin_get_menu_class
(
vtoy_class_directory
,
node
->
dir
);
if
(
!
dir_class
)
{
dir_class
=
"vtoydir"
;
}
dir_alias
=
ventoy_plugin_get_menu_alias
(
vtoy_alias_directory
,
node
->
dir
);
if
(
dir_alias
)
{
vtoy_ssprintf
(
g_tree_script_buf
,
g_tree_script_pos
,
"submenu
\"
%-10s %s
\"
--class=
\"
%s
\"
{
\n
"
,
"DIR"
,
dir_alias
,
dir_class
);
}
else
{
vtoy_ssprintf
(
g_tree_script_buf
,
g_tree_script_pos
,
"submenu
\"
%-10s [%s]
\"
--class=
\"
%s
\"
{
\n
"
,
"DIR"
,
node
->
dir
+
offset
,
dir_class
);
}
vtoy_ssprintf
(
g_tree_script_buf
,
g_tree_script_pos
,
"menuentry
\"
%-10s [../]
\"
--class=
\"
vtoyret
\"
VTOY_RET {
\n
"
...
...
@@ -1662,7 +1680,7 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
(
void
)
argc
;
(
void
)
args
;
debug
(
"select auto installation %d
\n
"
,
argc
);
debug
(
"select auto installation
argc:
%d
\n
"
,
argc
);
if
(
argc
<
1
)
{
...
...
@@ -1672,7 +1690,14 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
node
=
ventoy_plugin_find_install_template
(
args
[
0
]);
if
(
!
node
)
{
debug
(
"Install template not found for %s
\n
"
,
args
[
0
]);
debug
(
"Auto install template not found for %s
\n
"
,
args
[
0
]);
return
0
;
}
if
(
node
->
autosel
>=
0
&&
node
->
autosel
<=
node
->
templatenum
)
{
node
->
cursel
=
node
->
autosel
-
1
;
debug
(
"Auto install template auto select %d
\n
"
,
node
->
autosel
);
return
0
;
}
...
...
@@ -1720,7 +1745,7 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
(
void
)
argc
;
(
void
)
args
;
debug
(
"select persistece %d
\n
"
,
argc
);
debug
(
"select persiste
n
ce
argc:
%d
\n
"
,
argc
);
if
(
argc
<
1
)
{
...
...
@@ -1734,6 +1759,13 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
return
0
;
}
if
(
node
->
autosel
>=
0
&&
node
->
autosel
<=
node
->
backendnum
)
{
node
->
cursel
=
node
->
autosel
-
1
;
debug
(
"Persistence image auto select %d
\n
"
,
node
->
autosel
);
return
0
;
}
buf
=
(
char
*
)
grub_malloc
(
VTOY_MAX_SCRIPT_BUF
);
if
(
!
buf
)
{
...
...
@@ -1979,27 +2011,6 @@ static grub_err_t ventoy_cmd_dump_auto_install(grub_extcmd_context_t ctxt, int a
(
void
)
argc
;
(
void
)
args
;
{
grub_file_t
file
;
char
*
buf
;
char
name
[
128
];
file
=
grub_file_open
(
"(hd0,1)/ventoy/ventoy.disk.img.xz"
,
GRUB_FILE_TYPE_NONE
);
if
(
file
)
{
grub_printf
(
"Open File OK (size:%llu)
\n
"
,
(
ulonglong
)
file
->
size
);
buf
=
grub_malloc
(
file
->
size
);
grub_file_read
(
file
,
buf
,
file
->
size
);
grub_file_close
(
file
);
grub_snprintf
(
name
,
sizeof
(
name
),
"mem:0x%llx:size:%llu"
,
(
ulonglong
)(
ulong
)
buf
,
(
ulonglong
)
file
->
size
);
grub_printf
(
"<%s>
\n
"
,
name
);
}
}
ventoy_plugin_dump_auto_install
();
return
0
;
...
...
@@ -2267,6 +2278,32 @@ int ventoy_is_file_exist(const char *fmt, ...)
return
0
;
}
int
ventoy_is_dir_exist
(
const
char
*
fmt
,
...)
{
va_list
ap
;
int
len
;
char
*
pos
=
NULL
;
char
buf
[
256
]
=
{
0
};
grub_snprintf
(
buf
,
sizeof
(
buf
),
"%s"
,
"[ -d "
);
pos
=
buf
+
5
;
va_start
(
ap
,
fmt
);
len
=
grub_vsnprintf
(
pos
,
255
,
fmt
,
ap
);
va_end
(
ap
);
grub_strncpy
(
pos
+
len
,
" ]"
,
2
);
debug
(
"script exec %s
\n
"
,
buf
);
if
(
0
==
grub_script_execute_sourcecode
(
buf
))
{
return
1
;
}
return
0
;
}
static
int
ventoy_env_init
(
void
)
{
char
buf
[
64
];
...
...
@@ -2285,6 +2322,7 @@ static int ventoy_env_init(void)
if
(
g_grub_param
)
{
g_grub_param
->
grub_env_get
=
grub_env_get
;
g_grub_param
->
grub_env_printf
=
(
grub_env_printf_pf
)
grub_printf
;
grub_snprintf
(
buf
,
sizeof
(
buf
),
"%p"
,
g_grub_param
);
grub_env_set
(
"env_param"
,
buf
);
}
...
...
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
View file @
1d034f0a
...
...
@@ -460,6 +460,7 @@ int ventoy_cpio_newc_fill_head(void *buf, int filesize, const void *filedata, co
grub_file_t
ventoy_grub_file_open
(
enum
grub_file_type
type
,
const
char
*
fmt
,
...);
grub_uint64_t
ventoy_grub_get_file_size
(
const
char
*
fmt
,
...);
int
ventoy_is_file_exist
(
const
char
*
fmt
,
...);
int
ventoy_is_dir_exist
(
const
char
*
fmt
,
...);
int
ventoy_fill_data
(
grub_uint32_t
buflen
,
char
*
buffer
);
grub_err_t
ventoy_cmd_load_plugin
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
);
grub_err_t
ventoy_cmd_wimdows_reset
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
);
...
...
@@ -600,6 +601,7 @@ typedef struct install_template
int
pathlen
;
char
isopath
[
256
];
int
autosel
;
int
cursel
;
int
templatenum
;
file_fullpath
*
templatepath
;
...
...
@@ -612,6 +614,7 @@ typedef struct persistence_config
int
pathlen
;
char
isopath
[
256
];
int
autosel
;
int
cursel
;
int
backendnum
;
file_fullpath
*
backendpath
;
...
...
@@ -619,8 +622,12 @@ typedef struct persistence_config
struct
persistence_config
*
next
;
}
persistence_config
;
#define vtoy_alias_image_file 0
#define vtoy_alias_directory 1
typedef
struct
menu_alias
{
int
type
;
int
pathlen
;
char
isopath
[
256
];
char
alias
[
256
];
...
...
@@ -628,8 +635,12 @@ typedef struct menu_alias
struct
menu_alias
*
next
;
}
menu_alias
;
#define vtoy_class_image_file 0
#define vtoy_class_directory 1
typedef
struct
menu_class
{
int
type
;
int
patlen
;
char
pattern
[
256
];
char
class
[
64
];
...
...
@@ -654,8 +665,8 @@ persistence_config * ventoy_plugin_find_persistent(const char *isopath);
void
ventoy_plugin_dump_auto_install
(
void
);
int
ventoy_fill_windows_rtdata
(
void
*
buf
,
char
*
isopath
);
int
ventoy_plugin_get_persistent_chunklist
(
const
char
*
isopath
,
int
index
,
ventoy_img_chunk_list
*
chunk_list
);
const
char
*
ventoy_plugin_get_menu_alias
(
const
char
*
isopath
);
const
char
*
ventoy_plugin_get_menu_class
(
const
char
*
iso
name
);
const
char
*
ventoy_plugin_get_menu_alias
(
int
type
,
const
char
*
isopath
);
const
char
*
ventoy_plugin_get_menu_class
(
int
type
,
const
char
*
name
);
int
ventoy_get_block_list
(
grub_file_t
file
,
ventoy_img_chunk_list
*
chunklist
,
grub_disk_addr_t
start
);
int
ventoy_check_block_list
(
grub_file_t
file
,
ventoy_img_chunk_list
*
chunklist
,
grub_disk_addr_t
start
);
void
ventoy_plugin_dump_persistence
(
void
);
...
...
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c
View file @
1d034f0a
...
...
@@ -1144,7 +1144,7 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha
grub_memset
(
chain
,
0
,
sizeof
(
ventoy_chain_head
));
/* part 1: os parameter */
g_ventoy_chain_type
=
0
;
g_ventoy_chain_type
=
ventoy_chain_linux
;
ventoy_fill_os_param
(
file
,
&
(
chain
->
os_param
));
/* part 2: chain head */
...
...
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
View file @
1d034f0a
...
...
@@ -310,11 +310,13 @@ static int ventoy_plugin_check_fullpath
(
VTOY_JSON
*
json
,
const
char
*
isodisk
,
const
char
*
key
const
char
*
key
,
int
*
pathnum
)
{
int
rc
=
0
;
int
ret
=
0
;
int
cnt
=
0
;
VTOY_JSON
*
node
=
json
;
VTOY_JSON
*
child
=
NULL
;
...
...
@@ -334,6 +336,7 @@ static int ventoy_plugin_check_fullpath
if
(
JSON_TYPE_STRING
==
node
->
enDataType
)
{
cnt
=
1
;
ret
=
ventoy_plugin_check_path
(
isodisk
,
node
->
unData
.
pcStrVal
);
grub_printf
(
"%s: %s [%s]
\n
"
,
key
,
node
->
unData
.
pcStrVal
,
ret
?
"FAIL"
:
"OK"
);
}
...
...
@@ -350,10 +353,12 @@ static int ventoy_plugin_check_fullpath
rc
=
ventoy_plugin_check_path
(
isodisk
,
child
->
unData
.
pcStrVal
);
grub_printf
(
"%s: %s [%s]
\n
"
,
key
,
child
->
unData
.
pcStrVal
,
rc
?
"FAIL"
:
"OK"
);
ret
+=
rc
;
cnt
++
;
}
}
}
*
pathnum
=
cnt
;
return
ret
;
}
...
...
@@ -443,6 +448,8 @@ static int ventoy_plugin_parse_fullpath
static
int
ventoy_plugin_auto_install_check
(
VTOY_JSON
*
json
,
const
char
*
isodisk
)
{
int
pathnum
=
0
;
int
autosel
=
0
;
const
char
*
iso
=
NULL
;
VTOY_JSON
*
pNode
=
NULL
;
...
...
@@ -465,7 +472,19 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
if
(
0
==
ventoy_plugin_check_path
(
isodisk
,
iso
))
{
grub_printf
(
"image: %s [OK]
\n
"
,
iso
);
ventoy_plugin_check_fullpath
(
pNode
->
pstChild
,
isodisk
,
"template"
);
ventoy_plugin_check_fullpath
(
pNode
->
pstChild
,
isodisk
,
"template"
,
&
pathnum
);
if
(
JSON_SUCCESS
==
vtoy_json_get_int
(
pNode
->
pstChild
,
"autosel"
,
&
autosel
))
{
if
(
autosel
>=
0
&&
autosel
<=
pathnum
)
{
grub_printf
(
"autosel: %d [OK]
\n
"
,
autosel
);
}
else
{
grub_printf
(
"autosel: %d [FAIL]
\n
"
,
autosel
);
}
}
}
else
{
...
...
@@ -484,6 +503,7 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
static
int
ventoy_plugin_auto_install_entry
(
VTOY_JSON
*
json
,
const
char
*
isodisk
)
{
int
pathnum
=
0
;
int
autosel
=
0
;
const
char
*
iso
=
NULL
;
VTOY_JSON
*
pNode
=
NULL
;
install_template
*
node
=
NULL
;
...
...
@@ -522,6 +542,15 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
node
->
templatepath
=
templatepath
;
node
->
templatenum
=
pathnum
;
node
->
autosel
=
-
1
;
if
(
JSON_SUCCESS
==
vtoy_json_get_int
(
pNode
->
pstChild
,
"autosel"
,
&
autosel
))
{
if
(
autosel
>=
0
&&
autosel
<=
pathnum
)
{
node
->
autosel
=
autosel
;
}
}
if
(
g_install_template_head
)
{
node
->
next
=
g_install_template_head
;
...
...
@@ -538,6 +567,8 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
static
int
ventoy_plugin_persistence_check
(
VTOY_JSON
*
json
,
const
char
*
isodisk
)
{
int
autosel
=
0
;
int
pathnum
=
0
;
const
char
*
iso
=
NULL
;
VTOY_JSON
*
pNode
=
NULL
;
...
...
@@ -560,7 +591,19 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
if
(
0
==
ventoy_plugin_check_path
(
isodisk
,
iso
))
{
grub_printf
(
"image: %s [OK]
\n
"
,
iso
);
ventoy_plugin_check_fullpath
(
pNode
->
pstChild
,
isodisk
,
"backend"
);
ventoy_plugin_check_fullpath
(
pNode
->
pstChild
,
isodisk
,
"backend"
,
&
pathnum
);
if
(
JSON_SUCCESS
==
vtoy_json_get_int
(
pNode
->
pstChild
,
"autosel"
,
&
autosel
))
{
if
(
autosel
>=
0
&&
autosel
<=
pathnum
)
{
grub_printf
(
"autosel: %d [OK]
\n
"
,
autosel
);
}
else
{
grub_printf
(
"autosel: %d [FAIL]
\n
"
,
autosel
);
}
}
}
else
{
...
...
@@ -578,6 +621,7 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
static
int
ventoy_plugin_persistence_entry
(
VTOY_JSON
*
json
,
const
char
*
isodisk
)
{
int
autosel
=
0
;
int
pathnum
=
0
;
const
char
*
iso
=
NULL
;
VTOY_JSON
*
pNode
=
NULL
;
...
...
@@ -619,6 +663,15 @@ static int ventoy_plugin_persistence_entry(VTOY_JSON *json, const char *isodisk)
node
->
backendpath
=
backendpath
;
node
->
backendnum
=
pathnum
;
node
->
autosel
=
-
1
;
if
(
JSON_SUCCESS
==
vtoy_json_get_int
(
pNode
->
pstChild
,
"autosel"
,
&
autosel
))
{
if
(
autosel
>=
0
&&
autosel
<=
pathnum
)
{
node
->
autosel
=
autosel
;
}
}
if
(
g_persistence_head
)
{
node
->
next
=
g_persistence_head
;
...
...
@@ -635,7 +688,8 @@ static int ventoy_plugin_persistence_entry(VTOY_JSON *json, const char *isodisk)
static
int
ventoy_plugin_menualias_check
(
VTOY_JSON
*
json
,
const
char
*
isodisk
)
{
const
char
*
iso
=
NULL
;
int
type
;
const
char
*
path
=
NULL
;
const
char
*
alias
=
NULL
;
VTOY_JSON
*
pNode
=
NULL
;
...
...
@@ -649,17 +703,38 @@ static int ventoy_plugin_menualias_check(VTOY_JSON *json, const char *isodisk)
for
(
pNode
=
json
->
pstChild
;
pNode
;
pNode
=
pNode
->
pstNext
)
{
iso
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"image"
);
type
=
vtoy_alias_image_file
;
path
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"image"
);
if
(
!
path
)
{
path
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"dir"
);
type
=
vtoy_alias_directory
;
}
alias
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"alias"
);
if
(
iso
&&
iso
[
0
]
==
'/'
&&
alias
)
if
(
path
&&
path
[
0
]
==
'/'
&&
alias
)
{
if
(
ventoy_is_file_exist
(
"%s%s"
,
isodisk
,
iso
))
{
grub_printf
(
"image: <%s> [ OK ]
\n
"
,
iso
);
if
(
vtoy_alias_image_file
==
type
)
{
if
(
ventoy_is_file_exist
(
"%s%s"
,
isodisk
,
path
))
{
grub_printf
(
"image: <%s> [ OK ]
\n
"
,
path
);
}
else
{
grub_printf
(
"image: <%s> [ NOT EXIST ]
\n
"
,
path
);
}
}
else
{
grub_printf
(
"image: <%s> [ NOT EXIST ]
\n
"
,
iso
);
if
(
ventoy_is_dir_exist
(
"%s%s"
,
isodisk
,
path
))
{
grub_printf
(
"dir: <%s> [ OK ]
\n
"
,
path
);
}
else
{
grub_printf
(
"dir: <%s> [ NOT EXIST ]
\n
"
,
path
);
}
}
grub_printf
(
"alias: <%s>
\n\n
"
,
alias
);
...
...
@@ -671,7 +746,8 @@ static int ventoy_plugin_menualias_check(VTOY_JSON *json, const char *isodisk)
static
int
ventoy_plugin_menualias_entry
(
VTOY_JSON
*
json
,
const
char
*
isodisk
)
{
const
char
*
iso
=
NULL
;
int
type
;
const
char
*
path
=
NULL
;
const
char
*
alias
=
NULL
;
VTOY_JSON
*
pNode
=
NULL
;
menu_alias
*
node
=
NULL
;
...
...
@@ -698,14 +774,22 @@ static int ventoy_plugin_menualias_entry(VTOY_JSON *json, const char *isodisk)
for
(
pNode
=
json
->
pstChild
;
pNode
;
pNode
=
pNode
->
pstNext
)
{
iso
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"image"
);
type
=
vtoy_alias_image_file
;
path
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"image"
);
if
(
!
path
)
{
path
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"dir"
);
type
=
vtoy_alias_directory
;
}
alias
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"alias"
);
if
(
iso
&&
iso
[
0
]
==
'/'
&&
alias
)
if
(
path
&&
path
[
0
]
==
'/'
&&
alias
)
{
node
=
grub_zalloc
(
sizeof
(
menu_alias
));
if
(
node
)
{
node
->
pathlen
=
grub_snprintf
(
node
->
isopath
,
sizeof
(
node
->
isopath
),
"%s"
,
iso
);
node
->
type
=
type
;
node
->
pathlen
=
grub_snprintf
(
node
->
isopath
,
sizeof
(
node
->
isopath
),
"%s"
,
path
);
grub_snprintf
(
node
->
alias
,
sizeof
(
node
->
alias
),
"%s"
,
alias
);
if
(
g_menu_alias_head
)
...
...
@@ -723,6 +807,7 @@ static int ventoy_plugin_menualias_entry(VTOY_JSON *json, const char *isodisk)
static
int
ventoy_plugin_menuclass_entry
(
VTOY_JSON
*
json
,
const
char
*
isodisk
)
{
int
type
;
const
char
*
key
=
NULL
;
const
char
*
class
=
NULL
;
VTOY_JSON
*
pNode
=
NULL
;
...
...
@@ -751,13 +836,21 @@ static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
for
(
pNode
=
json
->
pstChild
;
pNode
;
pNode
=
pNode
->
pstNext
)
{
type
=
vtoy_class_image_file
;
key
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"key"
);
if
(
!
key
)
{
key
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"dir"
);
type
=
vtoy_class_directory
;
}
class
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"class"
);
if
(
key
&&
class
)
{
node
=
grub_zalloc
(
sizeof
(
menu_class
));
if
(
node
)
{
node
->
type
=
type
;
node
->
patlen
=
grub_snprintf
(
node
->
pattern
,
sizeof
(
node
->
pattern
),
"%s"
,
key
);
grub_snprintf
(
node
->
class
,
sizeof
(
node
->
class
),
"%s"
,
class
);
...
...
@@ -779,6 +872,7 @@ static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
static
int
ventoy_plugin_menuclass_check
(
VTOY_JSON
*
json
,
const
char
*
isodisk
)
{
int
type
;
const
char
*
key
=
NULL
;
const
char
*
class
=
NULL
;
VTOY_JSON
*
pNode
=
NULL
;
...
...
@@ -793,11 +887,18 @@ static int ventoy_plugin_menuclass_check(VTOY_JSON *json, const char *isodisk)
for
(
pNode
=
json
->
pstChild
;
pNode
;
pNode
=
pNode
->
pstNext
)
{
type
=
vtoy_class_image_file
;
key
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"key"
);
if
(
!
key
)
{
key
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"dir"
);
type
=
vtoy_class_directory
;
}
class
=
vtoy_json_get_string_ex
(
pNode
->
pstChild
,
"class"
);
if
(
key
&&
class
)
{
grub_printf
(
"
key
: <%s>
\n
"
,
key
);
grub_printf
(
"
%s
: <%s>
\n
"
,
(
type
==
vtoy_class_directory
)
?
"dir"
:
"key"
,
key
);
grub_printf
(
"class: <%s>
\n\n
"
,
class
);
}
}
...
...
@@ -901,7 +1002,7 @@ void ventoy_plugin_dump_auto_install(void)
for
(
node
=
g_install_template_head
;
node
;
node
=
node
->
next
)
{
grub_printf
(
"
\n
IMAGE:<%s>
\n
"
,
node
->
isopath
);
grub_printf
(
"
\n
IMAGE:<%s>
<%d>
\n
"
,
node
->
isopath
,
node
->
templatenum
);
for
(
i
=
0
;
i
<
node
->
templatenum
;
i
++
)
{
grub_printf
(
"SCRIPT %d:<%s>
\n
"
,
i
,
node
->
templatepath
[
i
].
path
);
...
...
@@ -920,7 +1021,7 @@ void ventoy_plugin_dump_persistence(void)
for
(
node
=
g_persistence_head
;
node
;
node
=
node
->
next
)
{
grub_printf
(
"
\n
IMAGE:<%s>
\n
"
,
node
->
isopath
);
grub_printf
(
"
\n
IMAGE:<%s>
<%d>
\n
"
,
node
->
isopath
,
node
->
backendnum
);
for
(
i
=
0
;
i
<
node
->
backendnum
;
i
++
)
{
...
...
@@ -1050,14 +1151,15 @@ end:
return
rc
;
}
const
char
*
ventoy_plugin_get_menu_alias
(
const
char
*
isopath
)
const
char
*
ventoy_plugin_get_menu_alias
(
int
type
,
const
char
*
isopath
)
{
menu_alias
*
node
=
NULL
;
int
len
=
(
int
)
grub_strlen
(
isopath
);
for
(
node
=
g_menu_alias_head
;
node
;
node
=
node
->
next
)
{
if
(
node
->
pathlen
==
len
&&
grub_strcmp
(
node
->
isopath
,
isopath
)
==
0
)
if
(
node
->
type
==
type
&&
node
->
pathlen
&&
node
->
pathlen
==
len
&&
grub_strcmp
(
node
->
isopath
,
isopath
)
==
0
)
{
return
node
->
alias
;
}
...
...
@@ -1066,23 +1168,35 @@ const char * ventoy_plugin_get_menu_alias(const char *isopath)
return
NULL
;
}
const
char
*
ventoy_plugin_get_menu_class
(
const
char
*
iso
name
)
const
char
*
ventoy_plugin_get_menu_class
(
int
type
,
const
char
*
name
)
{
menu_class
*
node
=
NULL
;
int
len
=
(
int
)
grub_strlen
(
isoname
);
for
(
node
=
g_menu_class_head
;
node
;
node
=
node
->
next
)
int
len
=
(
int
)
grub_strlen
(
name
);
if
(
vtoy_class_image_file
==
type
)
{
for
(
node
=
g_menu_class_head
;
node
;
node
=
node
->
next
)
{
if
(
node
->
type
==
type
&&
node
->
patlen
<=
len
&&
grub_strstr
(
name
,
node
->
pattern
))
{
return
node
->
class
;
}
}
}
else
{
i
f
(
node
->
patlen
<=
len
&&
grub_strstr
(
isoname
,
node
->
pattern
)
)
f
or
(
node
=
g_menu_class_head
;
node
;
node
=
node
->
next
)
{
return
node
->
class
;
if
(
node
->
type
==
type
&&
node
->
patlen
==
len
&&
grub_strncmp
(
name
,
node
->
pattern
,
len
)
==
0
)
{
return
node
->
class
;
}
}
}
return
NULL
;
}
grub_err_t
ventoy_cmd_plugin_check_json
(
grub_extcmd_context_t
ctxt
,
int
argc
,
char
**
args
)
{
int
i
=
0
;
...
...
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_windows.c
View file @
1d034f0a
...
...
@@ -332,7 +332,7 @@ grub_err_t ventoy_cmd_wimdows_reset(grub_extcmd_context_t ctxt, int argc, char *
g_wim_patch_head
=
NULL
;
g_wim_total_patch_count
=
0
;
g_wim_valid_patch_count
=
0
;
return
0
;
}
...
...
@@ -549,13 +549,9 @@ static wim_directory_entry * search_full_wim_dirent
{
subdir
=
(
wim_directory_entry
*
)((
char
*
)
meta_data
+
search
->
subdir
);
search
=
search_wim_dirent
(
subdir
,
*
path
);
if
(
!
search
)
{
debug
(
"%s search failed
\n
"
,
*
path
);
}
path
++
;
}
return
search
;
}
...
...
@@ -563,16 +559,18 @@ static wim_directory_entry * search_replace_wim_dirent(void *meta_data, wim_dire
{
wim_directory_entry
*
wim_dirent
=
NULL
;
const
char
*
winpeshl_path
[]
=
{
"Windows"
,
"System32"
,
"winpeshl.exe"
,
NULL
};
//const char *
pecmd
_path[] = { "Windows", "System32", "
PECMD
.exe", NULL };
//const char *
native
_path[] = { "Windows", "System32", "
native
.exe", NULL };
wim_dirent
=
search_full_wim_dirent
(
meta_data
,
dir
,
winpeshl_path
);
debug
(
"search winpeshl.exe %p
\n
"
,
wim_dirent
);
if
(
wim_dirent
)
{
return
wim_dirent
;
}
#if 0
wim_dirent = search_full_wim_dirent(meta_data, dir, pecmd_path);
wim_dirent = search_full_wim_dirent(meta_data, dir, native_path);
debug("search native.exe %p\n", wim_dirent);
if (wim_dirent)
{
return wim_dirent;
...
...
@@ -1385,7 +1383,7 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c
grub_memset
(
chain
,
0
,
sizeof
(
ventoy_chain_head
));
/* part 1: os parameter */
g_ventoy_chain_type
=
1
;
g_ventoy_chain_type
=
ventoy_chain_windows
;
ventoy_fill_os_param
(
file
,
&
(
chain
->
os_param
));
if
(
0
==
unknown_image
)
...
...
@@ -1597,7 +1595,7 @@ grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char
grub_memset
(
chain
,
0
,
sizeof
(
ventoy_chain_head
));
/* part 1: os parameter */
g_ventoy_chain_type
=
0
;
g_ventoy_chain_type
=
ventoy_chain_wim
;
ventoy_fill_os_param
(
file
,
&
(
chain
->
os_param
));
/* part 2: chain head */
...
...
GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h
View file @
1d034f0a
...
...
@@ -40,6 +40,15 @@ typedef enum ventoy_fs_type
ventoy_fs_max
}
ventoy_fs_type
;
typedef
enum
ventoy_chain_type
{
ventoy_chain_linux
=
0
,
/* 0: linux */
ventoy_chain_windows
,
/* 1: windows */
ventoy_chain_wim
,
/* 2: wim */
ventoy_chain_max
}
ventoy_chain_type
;
#pragma pack(1)
typedef
struct
ventoy_guid
...
...
@@ -109,7 +118,7 @@ typedef struct ventoy_os_param
*
* vtoy_reserved[0]: vtoy_break_level
* vtoy_reserved[1]: vtoy_debug_level
* vtoy_reserved[2]: vtoy_chain_type 0:Linux 1:Windows
* vtoy_reserved[2]: vtoy_chain_type 0:Linux 1:Windows
2:wimfile
* vtoy_reserved[3]: vtoy_iso_format 0:iso9660 1:udf
* vtoy_reserved[4]: vtoy_windows_cd_prompt
*
...
...
@@ -204,12 +213,13 @@ typedef struct ventoy_img_chunk_list
#define ventoy_filt_register grub_file_filter_register
typedef
const
char
*
(
*
grub_env_get_pf
)(
const
char
*
name
);
#pragma pack(1)
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
typedef
const
char
*
(
*
grub_env_get_pf
)(
const
char
*
name
);
typedef
int
(
*
grub_env_printf_pf
)(
const
char
*
fmt
,
...);
typedef
struct
ventoy_grub_param_file_replace
{
grub_uint32_t
magic
;
...
...
@@ -221,8 +231,8 @@ typedef struct ventoy_grub_param_file_replace
typedef
struct
ventoy_grub_param
{
grub_env_get_pf
grub_env_get
;
ventoy_grub_param_file_replace
file_replace
;
grub_env_printf_pf
grub_env_printf
;
}
ventoy_grub_param
;
#pragma pack()
...
...
GRUB2/MOD_SRC/grub-2.04/install.sh
View file @
1d034f0a
...
...
@@ -21,10 +21,10 @@ all_extra_modules="elf macho offsetio regexp file"
if
[
"
$1
"
=
"uefi"
]
;
then
all_modules
=
"
$net_modules_uefi
$all_modules_uefi
$all_extra_modules
"
grub-mkimage
-v
--directory
"
$VT_DIR
/GRUB2/INSTALL/lib/grub/x86_64-efi"
--prefix
'(,
msdos
2)/grub'
--output
"
$VT_DIR
/INSTALL/EFI/BOOT/grubx64_real.efi"
--format
'x86_64-efi'
--compression
'auto'
$all_modules_uefi
'fat'
'part_msdos'
grub-mkimage
-v
--directory
"
$VT_DIR
/GRUB2/INSTALL/lib/grub/x86_64-efi"
--prefix
'(,2)/grub'
--output
"
$VT_DIR
/INSTALL/EFI/BOOT/grubx64_real.efi"
--format
'x86_64-efi'
--compression
'auto'
$all_modules_uefi
'fat'
'part_msdos'
else
all_modules
=
"
$net_modules_legacy
$all_modules_legacy
"
grub-mkimage
-v
--directory
"
$VT_DIR
/GRUB2/INSTALL/lib/grub/i386-pc"
--prefix
'(,
msdos
2)/grub'
--output
"
$VT_DIR
/INSTALL/grub/i386-pc/core.img"
--format
'i386-pc'
--compression
'auto'
$all_modules_legacy
'fat'
'part_msdos'
'biosdisk'
grub-mkimage
-v
--directory
"
$VT_DIR
/GRUB2/INSTALL/lib/grub/i386-pc"
--prefix
'(,2)/grub'
--output
"
$VT_DIR
/INSTALL/grub/i386-pc/core.img"
--format
'i386-pc'
--compression
'auto'
$all_modules_legacy
'fat'
'part_msdos'
'biosdisk'
fi
grub-mknetdir
--modules
=
"
$all_modules
"
--net-directory
=
$VT_DIR
/GRUB2/PXE
--subdir
=
grub2
--locales
=
en@quot
||
exit
1
...
...
INSTALL/grub/debug.cfg
View file @
1d034f0a
submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
menuentry 'Check global control plugin configuration' {
menuentry 'Check global control plugin configuration'
--class=debug_control
{
set pager=1
vt_check_plugin_json $vt_plugin_path control $iso_path
...
...
@@ -61,6 +61,22 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
}
}
if [ "$grub_platform" != "pc" ]; then
submenu 'Ventoy UEFI Utilities' --class=debug_util {
menuentry 'Fixup Windows BlinitializeLibrary Failure' {
chainloader ${vtoy_path}/vtoyutil_x64.efi env_param=${env_param} ${vtdebug_flag} feature=fix_windows_mmap
boot
echo -e "\npress ENTER to exit ..."
read vtInputKey
}
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
echo 'Return ...'
}
}
fi
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
echo 'Return ...'
}
INSTALL/ventoy_pack.sh
View file @
1d034f0a
...
...
@@ -104,7 +104,7 @@ cd $CurDir
tar
-czvf
ventoy-
${
curver
}
-linux
.tar.gz
$tmpdir
rm
-f
ventoy-
${
curver
}
-windows
.zip
cp
-a
Ventoy2Disk.exe
$tmpdir
/
cp
-a
Ventoy2Disk
*
.exe
$tmpdir
/
cp
-a
$LANG_DIR
/languages.ini
$tmpdir
/ventoy/
rm
-rf
$tmpdir
/tool
rm
-f
$tmpdir
/
*
.sh
...
...
IPXE/ipxe_mod_code/ipxe-3fe683e/src/arch/x86/core/ventoy_vdisk.c
View file @
1d034f0a
...
...
@@ -574,7 +574,7 @@ int ventoy_boot_vdisk(void *data)
g_os_param_reserved
=
(
uint8_t
*
)(
g_chain
->
os_param
.
vtoy_reserved
);
/* Workaround for Windows & ISO9660 */
if
(
g_os_param_reserved
[
2
]
==
1
&&
g_os_param_reserved
[
3
]
==
0
)
if
(
g_os_param_reserved
[
2
]
==
ventoy_chain_windows
&&
g_os_param_reserved
[
3
]
==
0
)
{
g_fixup_iso9660_secover_enable
=
1
;
}
...
...
IPXE/ipxe_mod_code/ipxe-3fe683e/src/include/ventoy.h
View file @
1d034f0a
...
...
@@ -13,6 +13,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
typedef
enum
ventoy_chain_type
{
ventoy_chain_linux
=
0
,
/* 0: linux */
ventoy_chain_windows
,
/* 1: windows */
ventoy_chain_wim
,
/* 2: wim */
ventoy_chain_max
}
ventoy_chain_type
;
#pragma pack(1)
typedef
struct
ventoy_guid
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment