mirror of
https://github.com/ventoy/Ventoy.git
synced 2026-08-07 17:46:18 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cbdc5cf69 | ||
|
|
5903c8bf52 | ||
|
|
40895a09f6 | ||
|
|
ddc8e53156 | ||
|
|
e352b76731 | ||
|
|
5ebef5af77 | ||
|
|
9be9c7adb8 | ||
|
|
3751a47513 | ||
|
|
6dd3ed3ce3 | ||
|
|
ac300d7464 | ||
|
|
0963c1d396 | ||
|
|
a3995a0267 | ||
|
|
ba87af540b | ||
|
|
3d0d6c3147 | ||
|
|
2915e197e9 | ||
|
|
9bf8393cdf | ||
|
|
05d10437b0 | ||
|
|
083e5f72ea |
@@ -1231,65 +1231,6 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
#if defined (MDE_CPU_X64)
|
||||
|
||||
STATIC BOOLEAN EFIAPI IsSecureBootEnabled(VOID)
|
||||
{
|
||||
UINT8 SecureBoot = 0;
|
||||
UINTN DataSize;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DataSize = sizeof(SecureBoot);
|
||||
Status = gST->RuntimeServices->GetVariable(L"SecureBoot", &gEfiGlobalVariableGuid, NULL,
|
||||
&DataSize, &SecureBoot);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return SecureBoot ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
STATIC BOOLEAN EFIAPI IsSetupMode(VOID)
|
||||
{
|
||||
UINT8 SetupMode = 0;
|
||||
UINTN DataSize;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DataSize = sizeof(SetupMode);
|
||||
Status = gST->RuntimeServices->GetVariable(L"SetupMode", &gEfiGlobalVariableGuid, NULL,
|
||||
&DataSize, &SetupMode);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return SetupMode ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
STATIC BOOLEAN EFIAPI CheckVtoyShim(VOID)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_GUID Guid = VTOY_SHIM_POLICY_GUID;
|
||||
VOID *Prot = NULL;
|
||||
|
||||
/* If secure boot is not enabled or in SetupMode, nothing needed */
|
||||
if (!IsSecureBootEnabled() || IsSetupMode())
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&Prot);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
VtoyDebug("Failed to locate Vtoy Shim Protocol %lx\r\n", Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
EFI_STATUS EFIAPI VentoyEfiMain
|
||||
(
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
@@ -1299,15 +1240,6 @@ EFI_STATUS EFIAPI VentoyEfiMain
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *Protocol;
|
||||
|
||||
#if defined (MDE_CPU_X64)
|
||||
/* check that Ventoy Shim must exist */
|
||||
if (!CheckVtoyShim())
|
||||
{
|
||||
sleep(5);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
#endif
|
||||
|
||||
g_sector_flag_num = 512; /* initial value */
|
||||
|
||||
g_sector_flag = AllocatePool(g_sector_flag_num * sizeof(ventoy_sector_flag));
|
||||
|
||||
+108
-243
@@ -34,7 +34,14 @@
|
||||
|
||||
#define CUR_SBAT_VER 1
|
||||
|
||||
STATIC EFI_GUID gVtoySbatGUID = { 0xf755068a, 0xe04f, 0x452b, { 0x9d, 0x6d, 0x7c, 0x55, 0x96, 0xb3, 0xc0, 0x7d }};
|
||||
STATIC UINT8 gVtoyGrubSha256Hash[32] __attribute__((aligned(32))) = {
|
||||
0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,
|
||||
0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,
|
||||
0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,
|
||||
0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26
|
||||
};
|
||||
|
||||
STATIC BOOLEAN gGrubLaunched = FALSE;
|
||||
STATIC EFI_GUID gShimLockGUID = SHIM_LOCK_GUID;
|
||||
STATIC EFI_SECURITY_FILE_AUTHENTICATION_STATE gSysSecFileAuth = NULL;
|
||||
STATIC EFI_SECURITY2_FILE_AUTHENTICATION gSysSec2FileAuth = NULL;
|
||||
@@ -46,6 +53,10 @@ STATIC SHIM_LOCK gShimLock;
|
||||
STATIC EFI_EXIT_BOOT_SERVICES gSysExitBootServices = NULL;
|
||||
STATIC EFI_GET_VARIABLE gSysGetVariable = NULL;
|
||||
|
||||
STATIC VOID EFIAPI HookSystemService(VOID);
|
||||
STATIC VOID EFIAPI UnHookSystemService(VOID);
|
||||
|
||||
|
||||
STATIC VOID EFIAPI VtoyLog(CONST CHAR16 *Format, ...)
|
||||
{
|
||||
VA_LIST Marker;
|
||||
@@ -68,11 +79,15 @@ STATIC VOID EFIAPI DumpDevicePath(const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
|
||||
{
|
||||
CHAR16 *DPStr = NULL;
|
||||
|
||||
if (DevicePath)
|
||||
{
|
||||
DPStr = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
|
||||
}
|
||||
|
||||
if (DPStr)
|
||||
{
|
||||
vLog(L"%s", DPStr);
|
||||
gBS->FreePool(DPStr);
|
||||
FreePool(DPStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -80,35 +95,20 @@ STATIC VOID EFIAPI DumpDevicePath(const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID EFIAPI ShowSBWarning(BOOLEAN Reboot, const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
|
||||
STATIC VOID EFIAPI ShowSBWarning(const EFI_DEVICE_PATH_PROTOCOL *DevicePath)
|
||||
{
|
||||
UINTN Index = 0;
|
||||
|
||||
vLog(L"\r\n=======================================================");
|
||||
vLog(L"=======================================================\r\n");
|
||||
|
||||
DumpDevicePath(DevicePath);
|
||||
|
||||
vLog(L"\r\n####### Security Boot Violation ##########\r\n");
|
||||
vLog(L"\r\n####### Ventoy Security Boot Violation ##########\r\n");
|
||||
|
||||
vLog(L"=======================================================");
|
||||
vLog(L"=======================================================");
|
||||
|
||||
if (Reboot)
|
||||
{
|
||||
vLog(L"\r\n###### Press Enter to reboot... ######");
|
||||
if (gST->ConIn)
|
||||
{
|
||||
gST->ConIn->Reset(gST->ConIn, FALSE);
|
||||
gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &Index);
|
||||
}
|
||||
gRT->ResetSystem(EfiResetWarm, EFI_SECURITY_VIOLATION, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
VtoySleep(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
STATIC VOID * EFIAPI FindShimFuncAddr(UINT64 FuncOffset)
|
||||
@@ -212,144 +212,31 @@ END:
|
||||
}
|
||||
|
||||
|
||||
|
||||
STATIC EFI_STATUS EFIAPI ReadAuthFile
|
||||
STATIC EFI_STATUS EFIAPI CheckVtoyGrub
|
||||
(
|
||||
const EFI_DEVICE_PATH_PROTOCOL *DevicePathConst,
|
||||
VOID **Buffer,
|
||||
UINT32 *Size
|
||||
VOID *FileBuffer,
|
||||
UINTN FileSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN TmpSize = 0;
|
||||
CHAR16 *DpStr = NULL;
|
||||
EFI_HANDLE Handle = NULL;
|
||||
EFI_DEVICE_PATH *DevPath = NULL;
|
||||
EFI_DEVICE_PATH *TmpPath = NULL;
|
||||
EFI_FILE_IO_INTERFACE *FileIO = NULL;
|
||||
EFI_FILE *File = NULL;
|
||||
EFI_FILE *Root = NULL;
|
||||
UINT8 *FileData = NULL;
|
||||
EFI_FILE_INFO *FInfo = NULL;
|
||||
UINT8 Buf[1024];
|
||||
UINT8 Sha256Hash[64];
|
||||
|
||||
DevPath = TmpPath = DuplicateDevicePath(DevicePathConst);
|
||||
if (!DevPath)
|
||||
if (!FileBuffer || FileSize < sizeof(EFI_IMAGE_DOS_HEADER))
|
||||
{
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto END;
|
||||
vErr(L"Invalid FileBuffer:%p or size:%ld", FileBuffer, FileSize);
|
||||
return EFI_SECURITY_VIOLATION;
|
||||
}
|
||||
|
||||
Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &DevPath, &Handle);
|
||||
if (EFI_ERROR(Status))
|
||||
ZeroMem(Sha256Hash, sizeof(Sha256Hash));
|
||||
calc_sha256(FileBuffer, (UINT64)FileSize, Sha256Hash);
|
||||
|
||||
if (CompareMem(Sha256Hash, gVtoyGrubSha256Hash, 32) != 0)
|
||||
{
|
||||
vLog(L"Failed to locate simple file protocol %lx", Status);
|
||||
goto END;
|
||||
vErr(L"Ventoy hash check failed.");
|
||||
gRT->ResetSystem(EfiResetWarm, EFI_SECURITY_VIOLATION, 0, NULL);
|
||||
return EFI_SECURITY_VIOLATION;
|
||||
}
|
||||
|
||||
DpStr = ConvertDevicePathToText(DevPath, FALSE, TRUE);
|
||||
if (!DpStr)
|
||||
{
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto END;
|
||||
}
|
||||
|
||||
Status = gBS->HandleProtocol(Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FileIO);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
vLog(L"Failed to handle simple file protocol %lx", Status);
|
||||
goto END;
|
||||
}
|
||||
|
||||
Status = FileIO->OpenVolume(Handle, &Root);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
vLog(L"Failed to open drive volume (%lx)\n", Status);
|
||||
goto END;
|
||||
}
|
||||
|
||||
Status = Root->Open(Root, &File, DpStr, EFI_FILE_MODE_READ, 0);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
vLog(L"Failed to open file (%s) (%lx)\n", DpStr, Status);
|
||||
goto END;
|
||||
}
|
||||
|
||||
FInfo = (EFI_FILE_INFO *)Buf;
|
||||
TmpSize = sizeof(Buf);
|
||||
ZeroMem(FInfo, sizeof(EFI_FILE_INFO));
|
||||
|
||||
Status = File->GetInfo(File, &gEfiFileInfoGuid, &TmpSize, FInfo);
|
||||
if (EFI_ERROR(Status) || FInfo->FileSize == 0 || FInfo->FileSize >= 0xFFFFFFFFUL)
|
||||
{
|
||||
vLog(L"Failed to open file (%s) (%lx) Size(%ld)\n", DpStr, Status, (UINTN)FInfo->FileSize);
|
||||
goto END;
|
||||
}
|
||||
|
||||
FileData = AllocatePool(FInfo->FileSize);
|
||||
if (!FileData)
|
||||
{
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto END;
|
||||
}
|
||||
|
||||
TmpSize = FInfo->FileSize;
|
||||
Status = File->Read(File, &TmpSize, FileData);
|
||||
if (EFI_ERROR(Status) || TmpSize != (UINTN)FInfo->FileSize)
|
||||
{
|
||||
vLog(L"Failed to read file (%lx) Read:%ld Size:%ld\n", Status, TmpSize, (UINTN)FInfo->FileSize);
|
||||
goto END;
|
||||
}
|
||||
|
||||
|
||||
END:
|
||||
|
||||
if (File)
|
||||
{
|
||||
File->Close(File);
|
||||
}
|
||||
|
||||
if (Root)
|
||||
{
|
||||
Root->Close(Root);
|
||||
}
|
||||
|
||||
CheckFreePool(TmpPath);
|
||||
CheckFreePool(DpStr);
|
||||
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
CheckFreePool(FileData);
|
||||
}
|
||||
else
|
||||
{
|
||||
*Buffer = FileData;
|
||||
*Size = (UINT32)FInfo->FileSize;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
STATIC BOOLEAN VtoyCheckRevoke(VOID *Buffer, UINTN Size)
|
||||
{
|
||||
UINT32 uiVer = 0;
|
||||
EFI_IMAGE_DOS_HEADER *DosHead = (EFI_IMAGE_DOS_HEADER *)Buffer;
|
||||
|
||||
if (Size > sizeof(EFI_IMAGE_DOS_HEADER) && DosHead->e_magic == 0x5A4D)
|
||||
{
|
||||
if (CompareMem(DosHead->e_res2, &gVtoySbatGUID, 16) == 0)
|
||||
{
|
||||
CopyMem(&uiVer, DosHead->e_res2 + 8, 4);
|
||||
if (uiVer < CUR_SBAT_VER)
|
||||
{
|
||||
vLog(L"Ventoy EFI file revoke (%u < %u)", uiVer, CUR_SBAT_VER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
STATIC EFI_STATUS EFIAPI SecurityPolicyAuth
|
||||
@@ -359,60 +246,18 @@ STATIC EFI_STATUS EFIAPI SecurityPolicyAuth
|
||||
const EFI_DEVICE_PATH_PROTOCOL *DevicePathConst
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN bRevokeChkOK = TRUE;
|
||||
UINT32 Size = 0;
|
||||
VOID *Buffer = NULL;
|
||||
|
||||
/* Just return OK if the user choose to bypass SB */
|
||||
if (gVtoyByPassSB)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Step 1:
|
||||
* Use original UEFI firmware auth API.
|
||||
* If it's OK, it may be signed with Microsoft UEFI CA. (e.g. bootmgr/shim/...)
|
||||
* Some old UEFI firmware (without Security2 protocol) will hang when run OpenVolume.
|
||||
* So finally I decide not to support such UEFI firmware.
|
||||
* It means that for UEFI firmware before 2.5 (about 2015) Ventoy only supports Bypass policy.
|
||||
*
|
||||
*/
|
||||
if (gSysSecFileAuth)
|
||||
{
|
||||
Status = gSysSecFileAuth(This, AuthenticationStatus, DevicePathConst);
|
||||
if (!EFI_ERROR(Status))
|
||||
{
|
||||
|
||||
(VOID)This;
|
||||
(VOID)AuthenticationStatus;
|
||||
(VOID)DevicePathConst;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Step 2:
|
||||
* Use shim verify API.
|
||||
* If it's OK, it may be signed with a MOK key. (e.g. Ventoy EFI files)
|
||||
*/
|
||||
if (gShimLock.Verify)
|
||||
{
|
||||
Status = ReadAuthFile(DevicePathConst, &Buffer, &Size);
|
||||
if (!EFI_ERROR(Status))
|
||||
{
|
||||
Status = gShimLock.Verify(Buffer, Size);
|
||||
if (!EFI_ERROR(Status))
|
||||
{
|
||||
bRevokeChkOK = VtoyCheckRevoke(Buffer, Size);
|
||||
if (bRevokeChkOK)
|
||||
{
|
||||
FreePool(Buffer);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
FreePool(Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
ShowSBWarning(!bRevokeChkOK, DevicePathConst);
|
||||
|
||||
return EFI_SECURITY_VIOLATION;
|
||||
}
|
||||
|
||||
STATIC EFI_STATUS EFIAPI Security2PolicyAuth
|
||||
(
|
||||
@@ -424,7 +269,6 @@ STATIC EFI_STATUS EFIAPI Security2PolicyAuth
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN bRevokeChkOK = TRUE;
|
||||
|
||||
/* Just return OK if the user choose to bypass SB */
|
||||
if (gVtoyByPassSB)
|
||||
@@ -432,6 +276,11 @@ STATIC EFI_STATUS EFIAPI Security2PolicyAuth
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (!gGrubLaunched)
|
||||
{
|
||||
return CheckVtoyGrub(FileBuffer, FileSize);
|
||||
}
|
||||
|
||||
/*
|
||||
* Step 1:
|
||||
* Use original UEFI firmware auth API.
|
||||
@@ -458,17 +307,13 @@ STATIC EFI_STATUS EFIAPI Security2PolicyAuth
|
||||
{
|
||||
Status = gShimLock.Verify(FileBuffer, (UINT32)FileSize);
|
||||
if (!EFI_ERROR(Status))
|
||||
{
|
||||
bRevokeChkOK = VtoyCheckRevoke(FileBuffer, FileSize);
|
||||
if (bRevokeChkOK)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShowSBWarning(!bRevokeChkOK, DevicePath);
|
||||
ShowSBWarning(DevicePath);
|
||||
|
||||
return EFI_SECURITY_VIOLATION;
|
||||
}
|
||||
@@ -549,6 +394,11 @@ STATIC VOID EFIAPI VtoyCheckSB(VOID)
|
||||
gVtoyByPassSB = FALSE;
|
||||
}
|
||||
|
||||
STATIC VOID EFIAPI VtoyLaunched(VOID)
|
||||
{
|
||||
gGrubLaunched = TRUE;
|
||||
}
|
||||
|
||||
STATIC VOID EFIAPI UnInstallVtoyShimProtocol(VOID)
|
||||
{
|
||||
EFI_GUID Guid = VTOY_SHIM_POLICY_GUID;
|
||||
@@ -568,6 +418,7 @@ STATIC EFI_STATUS EFIAPI InstallVtoyShimProtocol(VOID)
|
||||
|
||||
gVtoyShimProtocol.ByPassSB = VtoyByPassSB;
|
||||
gVtoyShimProtocol.CheckSB = VtoyCheckSB;
|
||||
gVtoyShimProtocol.Launched = VtoyLaunched;
|
||||
|
||||
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&Prot);
|
||||
if (!EFI_ERROR(Status))
|
||||
@@ -623,9 +474,7 @@ STATIC BOOLEAN EFIAPI IsSetupMode(VOID)
|
||||
STATIC EFI_STATUS EFIAPI ShimEfiMain
|
||||
(
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable,
|
||||
IN BOOLEAN IsSecureBoot,
|
||||
IN BOOLEAN IsSetup
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -633,17 +482,6 @@ STATIC EFI_STATUS EFIAPI ShimEfiMain
|
||||
shim_void_func_pf Func1 = NULL;
|
||||
shim_void_func_pf Func2 = NULL;
|
||||
|
||||
/* If secure boot is not enabled or in SetupMode, nothing needed, just launch Ventoy grub */
|
||||
if (!IsSecureBoot || IsSetup)
|
||||
{
|
||||
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
vErr(L"Failed to launch %s", REAL_GRUB_FILE);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* We must be launched by shim */
|
||||
Status = gBS->LocateProtocol(&gShimLockGUID, NULL, (VOID**)&ShimLock);
|
||||
if (EFI_ERROR(Status) || !ShimLock)
|
||||
@@ -691,6 +529,7 @@ STATIC EFI_STATUS EFIAPI ShimEfiMain
|
||||
Func1(); /* call shim unhook_system_services() */
|
||||
Func2(); /* call shim uninstall_shim_protocols() */
|
||||
|
||||
HookSystemService();
|
||||
|
||||
/* Hook the system security policy */
|
||||
Status = HookSecurityPolicy();
|
||||
@@ -700,6 +539,7 @@ STATIC EFI_STATUS EFIAPI ShimEfiMain
|
||||
goto END;
|
||||
}
|
||||
|
||||
|
||||
/* Finally launch Ventoy grub */
|
||||
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
|
||||
if (EFI_ERROR(Status))
|
||||
@@ -715,24 +555,11 @@ END:
|
||||
|
||||
UnInstallVtoyShimProtocol();
|
||||
|
||||
UnHookSystemService();
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
STATIC EFI_STATUS EFIAPI VtoyExitBootServices
|
||||
(
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN UINTN MapKey
|
||||
)
|
||||
{
|
||||
UnHookSecurityPolicy();
|
||||
UnInstallVtoyShimProtocol();
|
||||
|
||||
gST->RuntimeServices->GetVariable = gSysGetVariable;
|
||||
gBS->ExitBootServices = gSysExitBootServices;
|
||||
|
||||
return gSysExitBootServices(ImageHandle, MapKey);
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI VtoyGetVariable
|
||||
(
|
||||
IN CHAR16 *VariableName,
|
||||
@@ -763,6 +590,48 @@ EFI_STATUS EFIAPI VtoyGetVariable
|
||||
return Status;
|
||||
}
|
||||
|
||||
STATIC VOID EFIAPI UnHookSystemService(VOID)
|
||||
{
|
||||
if (gSysExitBootServices)
|
||||
{
|
||||
gBS->ExitBootServices = gSysExitBootServices;
|
||||
gSysExitBootServices = NULL;
|
||||
}
|
||||
|
||||
if (gSysGetVariable)
|
||||
{
|
||||
gST->RuntimeServices->GetVariable = gSysGetVariable;
|
||||
gSysGetVariable = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
STATIC EFI_STATUS EFIAPI VtoyExitBootServices
|
||||
(
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN UINTN MapKey
|
||||
)
|
||||
{
|
||||
EFI_EXIT_BOOT_SERVICES SysExitBS;
|
||||
|
||||
/* UnHookSystemService will set gSysExitBootServices NULL */
|
||||
SysExitBS = gSysExitBootServices;
|
||||
|
||||
UnHookSecurityPolicy();
|
||||
UnInstallVtoyShimProtocol();
|
||||
UnHookSystemService();
|
||||
|
||||
return SysExitBS(ImageHandle, MapKey);
|
||||
}
|
||||
|
||||
STATIC VOID EFIAPI HookSystemService(VOID)
|
||||
{
|
||||
gSysExitBootServices = gBS->ExitBootServices;
|
||||
gBS->ExitBootServices = VtoyExitBootServices;
|
||||
|
||||
gSysGetVariable = gST->RuntimeServices->GetVariable;
|
||||
gST->RuntimeServices->GetVariable = VtoyGetVariable;
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI VtoyShimEfiMain
|
||||
(
|
||||
@@ -779,20 +648,16 @@ EFI_STATUS EFIAPI VtoyShimEfiMain
|
||||
|
||||
if (!IsSecureBoot || IsSetup)
|
||||
{
|
||||
Status = ShimEfiMain(ImageHandle, SystemTable, IsSecureBoot, IsSetup);
|
||||
/* If secure boot is not enabled or in SetupMode, nothing needed, just launch Ventoy grub */
|
||||
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
vErr(L"Failed to launch %s", REAL_GRUB_FILE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gSysExitBootServices = gBS->ExitBootServices;
|
||||
gBS->ExitBootServices = VtoyExitBootServices;
|
||||
|
||||
gSysGetVariable = gST->RuntimeServices->GetVariable;
|
||||
gST->RuntimeServices->GetVariable = VtoyGetVariable;
|
||||
|
||||
Status = ShimEfiMain(ImageHandle, SystemTable, IsSecureBoot, IsSetup);
|
||||
|
||||
gBS->ExitBootServices = gSysExitBootServices;
|
||||
gST->RuntimeServices->GetVariable = gSysGetVariable;
|
||||
Status = ShimEfiMain(ImageHandle, SystemTable);
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
||||
@@ -88,6 +88,7 @@ typedef VOID (*shim_void_func_pf)(VOID);
|
||||
#define VtoySleep(sec) gBS->Stall(1000000 * (sec))
|
||||
#define vLog(fmt, ...) VtoyLog(fmt "\r\n", ##__VA_ARGS__)
|
||||
#define vErr(fmt, ...) VtoyLog(fmt "\r\n", ##__VA_ARGS__); VtoySleep(5)
|
||||
#define vDbg(fmt, ...) VtoyLog(fmt "\r\n", ##__VA_ARGS__); VtoySleep(2)
|
||||
|
||||
#define CheckFreePool(p) \
|
||||
do { \
|
||||
@@ -100,15 +101,16 @@ do { \
|
||||
|
||||
#define VTOY_SHIM_POLICY_GUID {0x90a29d14, 0x3968, 0x48fe, { 0x85, 0x81, 0x6b, 0x7f, 0x7d, 0xc4, 0x70, 0x55 }};
|
||||
|
||||
|
||||
typedef VOID (EFIAPI *VTOY_BYPASS_SB)(VOID);
|
||||
typedef VOID (EFIAPI *VTOY_CHECK_SB)(VOID);
|
||||
typedef VOID (EFIAPI *VTOY_LAUNCHED)(VOID);
|
||||
typedef struct _VTOY_SHIM{
|
||||
VTOY_BYPASS_SB ByPassSB;
|
||||
VTOY_BYPASS_SB CheckSB;
|
||||
VTOY_LAUNCHED Launched;
|
||||
} VTOY_SHIM;
|
||||
|
||||
CONST UINT8 * ventoy_get_der_data(UINT32 *Len);
|
||||
void calc_sha256(const void *data, UINT64 len, void *output);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
[Sources]
|
||||
VtoyShim.h
|
||||
VtoyShim.c
|
||||
sha256.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
/******************************************************************************
|
||||
* VtoyShim.c
|
||||
*
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
||||
|
||||
static const UINT32 sha256_initial_h[8]
|
||||
= { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
|
||||
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
|
||||
|
||||
static const UINT32 sha256_round_k[64]
|
||||
= { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
|
||||
0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
||||
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
|
||||
0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
|
||||
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
||||
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
|
||||
0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
|
||||
0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
||||
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 };
|
||||
|
||||
static void sha256_endian_reverse64(UINT64 input, UINT8 *output) {
|
||||
output[7] = (input >> 0) & 0xff;
|
||||
output[6] = (input >> 8) & 0xff;
|
||||
output[5] = (input >> 16) & 0xff;
|
||||
output[4] = (input >> 24) & 0xff;
|
||||
output[3] = (input >> 32) & 0xff;
|
||||
output[2] = (input >> 40) & 0xff;
|
||||
output[1] = (input >> 48) & 0xff;
|
||||
output[0] = (input >> 56) & 0xff;
|
||||
}
|
||||
|
||||
static UINT32 sha256_endian_read32(UINT8 *input) {
|
||||
UINT32 output = 0;
|
||||
output |= (input[0] << 24);
|
||||
output |= (input[1] << 16);
|
||||
output |= (input[2] << 8);
|
||||
output |= (input[3] << 0);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static void sha256_endian_reverse32(UINT32 input, UINT8 *output) {
|
||||
output[3] = (input >> 0) & 0xff;
|
||||
output[2] = (input >> 8) & 0xff;
|
||||
output[1] = (input >> 16) & 0xff;
|
||||
output[0] = (input >> 24) & 0xff;
|
||||
}
|
||||
|
||||
static UINT32 sha256_ror(UINT32 input, UINT32 by) {
|
||||
return (input >> by) | (((input & ((1 << by) - 1))) << (32 - by));
|
||||
}
|
||||
|
||||
void calc_sha256(const void *data, UINT64 len, void *output)
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
UINT8 padding[80];
|
||||
UINT64 current = (len + 1) % 64;
|
||||
// want to be == 56 % 64.
|
||||
UINT64 needed = (64 + 56 - current) % 64;
|
||||
UINT64 extra = needed + 9;
|
||||
UINT64 total = len + extra;
|
||||
UINT32 v[8];
|
||||
UINT64 cursor = 0;
|
||||
|
||||
for(i = 1; i < 80; i++)
|
||||
{
|
||||
padding[i] = 0;
|
||||
}
|
||||
padding[0] = 0x80;
|
||||
|
||||
sha256_endian_reverse64(len * 8, padding + total - len - 8);
|
||||
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
v[i] = sha256_initial_h[i];
|
||||
}
|
||||
|
||||
for(cursor = 0; cursor * 64 < total; cursor++)
|
||||
{
|
||||
UINT32 t[8];
|
||||
UINT32 w[64];
|
||||
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
t[i] = v[i];
|
||||
}
|
||||
|
||||
|
||||
if(cursor * 64 + 64 <= len)
|
||||
{
|
||||
for(j = 0; j < 16; j++)
|
||||
{
|
||||
w[j] = sha256_endian_read32((UINT8 *)data + cursor * 64 + j * 4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cursor * 64 < len)
|
||||
{
|
||||
UINT64 size = len - cursor * 64;
|
||||
if(size > 0)
|
||||
{
|
||||
CopyMem(w, (UINT8 *)data + cursor * 64, size);
|
||||
}
|
||||
CopyMem((UINT8 *)w + size, padding, 64 - size);
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT64 off = (cursor * 64 - len) % 64;
|
||||
CopyMem((UINT8 *)w, padding + off, 64);
|
||||
}
|
||||
|
||||
for(j = 0; j < 16; j++)
|
||||
{
|
||||
w[j] = sha256_endian_read32((UINT8 *)&w[j]);
|
||||
}
|
||||
}
|
||||
|
||||
for(j = 16; j < 64; j++)
|
||||
{
|
||||
UINT32 s1 = sha256_ror(w[j - 2], 17) ^ sha256_ror(w[j - 2], 19) ^ (w[j - 2] >> 10);
|
||||
UINT32 s0 = sha256_ror(w[j - 15], 7) ^ sha256_ror(w[j - 15], 18) ^ (w[j - 15] >> 3);
|
||||
w[j] = s1 + w[j - 7] + s0 + w[j - 16];
|
||||
}
|
||||
|
||||
for(j = 0; j < 64; j++)
|
||||
{
|
||||
UINT32 ch = (t[4] & t[5]) ^ (~t[4] & t[6]);
|
||||
UINT32 maj = (t[0] & t[1]) ^ (t[0] & t[2]) ^ (t[1] & t[2]);
|
||||
UINT32 S0 = sha256_ror(t[0], 2) ^ sha256_ror(t[0], 13) ^ sha256_ror(t[0], 22);
|
||||
UINT32 S1 = sha256_ror(t[4], 6) ^ sha256_ror(t[4], 11) ^ sha256_ror(t[4], 25);
|
||||
UINT32 t1 = t[7] + S1 + ch + sha256_round_k[j] + w[j];
|
||||
UINT32 t2 = S0 + maj;
|
||||
|
||||
t[7] = t[6];
|
||||
t[6] = t[5];
|
||||
t[5] = t[4];
|
||||
t[4] = t[3] + t1;
|
||||
t[3] = t[2];
|
||||
t[2] = t[1];
|
||||
t[1] = t[0];
|
||||
t[0] = t1 + t2;
|
||||
}
|
||||
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
v[i] += t[i];
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
sha256_endian_reverse32(v[i], (UINT8 *)output + i * 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,66 +145,6 @@ STATIC EFI_STATUS ParseCmdline(IN EFI_HANDLE ImageHandle)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
#if defined (MDE_CPU_X64)
|
||||
|
||||
STATIC BOOLEAN EFIAPI IsSecureBootEnabled(VOID)
|
||||
{
|
||||
UINT8 SecureBoot = 0;
|
||||
UINTN DataSize;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DataSize = sizeof(SecureBoot);
|
||||
Status = gST->RuntimeServices->GetVariable(L"SecureBoot", &gEfiGlobalVariableGuid, NULL,
|
||||
&DataSize, &SecureBoot);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return SecureBoot ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
STATIC BOOLEAN EFIAPI IsSetupMode(VOID)
|
||||
{
|
||||
UINT8 SetupMode = 0;
|
||||
UINTN DataSize;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DataSize = sizeof(SetupMode);
|
||||
Status = gST->RuntimeServices->GetVariable(L"SetupMode", &gEfiGlobalVariableGuid, NULL,
|
||||
&DataSize, &SetupMode);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return SetupMode ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
||||
STATIC BOOLEAN EFIAPI CheckVtoyShim(VOID)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_GUID Guid = VTOY_SHIM_POLICY_GUID;
|
||||
VOID *Prot = NULL;
|
||||
|
||||
/* If secure boot is not enabled or in SetupMode, nothing needed */
|
||||
if (!IsSecureBootEnabled() || IsSetupMode())
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&Prot);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
gST->ConOut->OutputString(gST->ConOut, L"Can not locate Vtoy Shim\r\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
EFI_STATUS EFIAPI VtoyUtilEfiMain
|
||||
(
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
@@ -214,15 +154,6 @@ EFI_STATUS EFIAPI VtoyUtilEfiMain
|
||||
UINTN i;
|
||||
UINTN Len;
|
||||
|
||||
#if defined (MDE_CPU_X64)
|
||||
/* check that Ventoy Shim must exist */
|
||||
if (!CheckVtoyShim())
|
||||
{
|
||||
gBS->Stall(5 * 1000000);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
#endif
|
||||
|
||||
ParseCmdline(ImageHandle);
|
||||
|
||||
for (i = 0; gCurFeature && i < ARRAY_SIZE(gFeatureList); i++)
|
||||
|
||||
@@ -314,6 +314,25 @@ static void ventoy_get_uefi_version(char *str, grub_size_t len)
|
||||
grub_snprintf(str, len, "%s.%d", str, uefi_minor_2);
|
||||
}
|
||||
|
||||
static void ventoy_get_pi_version(char *str, grub_size_t len)
|
||||
{
|
||||
grub_uint32_t data = 0;
|
||||
grub_efi_uintn_t i = 0;
|
||||
grub_efi_guid_t dxest =
|
||||
{ 0x05ad34ba, 0x6f02, 0x4214, {0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } };
|
||||
|
||||
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||
{
|
||||
if (grub_memcmp(&dxest, &grub_efi_system_table->configuration_table[i].vendor_guid, 16) == 0)
|
||||
{
|
||||
grub_memcpy(&data, (char *)grub_efi_system_table->configuration_table[i].vendor_table + 8, 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
grub_snprintf(str, len, "%d.%d", (data >> 16) & 0xFFFF, (data & 0xFFFF) / 10);
|
||||
}
|
||||
|
||||
int ventoy_set_sb_policy(void)
|
||||
{
|
||||
const char *env = NULL;
|
||||
@@ -399,24 +418,23 @@ static int ventoy_secure_boot_init(void)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* When SecureBoot enabled, Ventoy grub must be launched by Ventoy Shim.
|
||||
* Currently only x86_64 support this feature.
|
||||
*/
|
||||
if (g_ventoy_plat_data == VTOY_PLAT_X86_64_UEFI)
|
||||
{
|
||||
g_vtoy_shim = grub_efi_locate_protocol(&ProtGuid, NULL);
|
||||
if (g_vtoy_shim == NULL || g_vtoy_shim->ByPassSB == NULL || g_vtoy_shim->CheckSB == NULL)
|
||||
if (g_vtoy_shim == NULL || g_vtoy_shim->ByPassSB == NULL ||
|
||||
g_vtoy_shim->CheckSB == NULL || g_vtoy_shim->Launched == NULL)
|
||||
{
|
||||
grub_cls();
|
||||
grub_printf(VTOY_WARNING"\n");
|
||||
grub_printf(VTOY_WARNING"\n");
|
||||
grub_printf(VTOY_WARNING"\n\n\n");
|
||||
|
||||
grub_printf("Ventoy grub is not launched by Ventoy shim.\n\n");
|
||||
grub_refresh();
|
||||
|
||||
ventoy_prompt_end();
|
||||
/*
|
||||
* Generally when SecureBoot enabled, Ventoy grub must be launched by Ventoy Shim.
|
||||
* But there are some exceptions:
|
||||
* 1. Ventoy key was enrolled directly to the UEFI DB
|
||||
* 2. Some UEFI firmware (MSI) has Image Execution Policy as Always Execute which
|
||||
* means Secure Boot is effectively disabled.
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
g_vtoy_shim->Launched();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,8 +501,12 @@ static int ventoy_hwinfo_init(void)
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
ventoy_get_uefi_version(str, sizeof(str));
|
||||
ventoy_env_export("grub_uefi_version", str);
|
||||
|
||||
ventoy_get_pi_version(str, sizeof(str));
|
||||
ventoy_env_export("grub_pi_version", str);
|
||||
#else
|
||||
ventoy_env_export("grub_uefi_version", "NA");
|
||||
ventoy_env_export("grub_pi_version", "NA");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -4752,23 +4752,10 @@ static grub_err_t ventoy_cmd_img_unhook_root(grub_extcmd_context_t ctxt, int arg
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
static grub_err_t ventoy_cmd_check_secureboot_var(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int ret = 1;
|
||||
grub_uint8_t *var = NULL;
|
||||
grub_size_t size;
|
||||
grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
var = grub_efi_get_variable("SecureBoot", &global, &size);
|
||||
if (var && *var == 1)
|
||||
{
|
||||
grub_free(var);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return g_sys_sb ? 0 : 1;
|
||||
}
|
||||
#else
|
||||
static grub_err_t ventoy_cmd_check_secureboot_var(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
@@ -6464,6 +6451,10 @@ static grub_err_t ventoy_cmd_sb_info(grub_extcmd_context_t ctxt, int argc, char
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
const char *policy = NULL;
|
||||
grub_efi_guid_t security =
|
||||
{ 0xA46423E3, 0x4617, 0x49f1, {0xB9, 0xFF, 0xD1, 0xBF, 0xA9, 0x11, 0x58, 0x39 } };
|
||||
grub_efi_guid_t security2 =
|
||||
{ 0x94ab2f58, 0x1438, 0x4ef1, {0x91, 0x52, 0x18, 0x94, 0x1a, 0x3a, 0x0e, 0x68 } };
|
||||
|
||||
if (g_sb_policy == VTOY_SB_POLICY_BYPASS)
|
||||
{
|
||||
@@ -6478,8 +6469,10 @@ static grub_err_t ventoy_cmd_sb_info(grub_extcmd_context_t ctxt, int argc, char
|
||||
policy = "XXX";
|
||||
}
|
||||
|
||||
grub_printf("UEFI Firmware Secure Boot: %s\n", g_sys_sb ? "Enable" : "Disable");
|
||||
grub_printf("Ventoy Secure Boot Policy: %s\n", policy);
|
||||
grub_printf("UEFI Security %s\n", grub_efi_locate_protocol(&security, NULL) ? "Yes" : "No");
|
||||
grub_printf("UEFI Security2 %s\n", grub_efi_locate_protocol(&security2, NULL) ? "Yes" : "No");
|
||||
grub_printf("Ventoy Secure Policy %s\n", policy);
|
||||
|
||||
#else
|
||||
grub_printf("Non EFI mode!\n");
|
||||
#endif
|
||||
|
||||
@@ -199,9 +199,11 @@ typedef struct cpio_newc_header
|
||||
|
||||
typedef void (*VTOY_BYPASS_SB)(void);
|
||||
typedef void (*VTOY_CHECK_SB)(void);
|
||||
typedef void (*VTOY_LAUNCHED)(void);
|
||||
typedef struct _VTOY_SHIM{
|
||||
VTOY_BYPASS_SB ByPassSB;
|
||||
VTOY_CHECK_SB CheckSB;
|
||||
VTOY_LAUNCHED Launched;
|
||||
} VTOY_SHIM;
|
||||
|
||||
|
||||
|
||||
@@ -525,42 +525,18 @@ grub_err_t ventoy_cmd_unix_freebsd_ver(grub_extcmd_context_t ctxt, int argc, cha
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
static int ventoy_freebsd_ver_elf(int bit64, grub_elf_t elf, const char *section, const char *env, char *data)
|
||||
{
|
||||
int j;
|
||||
int k;
|
||||
grub_elf_t elf = NULL;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
int ret = 1;
|
||||
char *str = NULL;
|
||||
void *hdr = NULL;
|
||||
grub_off_t offset = 0;
|
||||
grub_uint32_t len = 0;
|
||||
char *str = NULL;
|
||||
char *data = NULL;
|
||||
void *hdr = NULL;
|
||||
char ver[64] = {0};
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
debug("Invalid argc %d\n", argc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
data = grub_zalloc(8192);
|
||||
if (!data)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
elf = grub_elf_open(args[0], GRUB_FILE_TYPE_LINUX_INITRD);
|
||||
if (!elf)
|
||||
{
|
||||
debug("Failed to open file %s\n", args[0]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (args[1][0] == '6')
|
||||
if (bit64)
|
||||
{
|
||||
Elf64_Ehdr *e = &(elf->ehdr.ehdr64);
|
||||
Elf64_Shdr *h;
|
||||
@@ -592,11 +568,11 @@ grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc,
|
||||
|
||||
for (t = h, i = 0; i < e->e_shnum; i++)
|
||||
{
|
||||
if (grub_strcmp(str + t->sh_name, ".data") == 0)
|
||||
if (grub_strcmp(str + t->sh_name, section) == 0)
|
||||
{
|
||||
offset = t->sh_offset;
|
||||
len = t->sh_size;
|
||||
debug("find .data section at %u %u\n", (grub_uint32_t)offset, len);
|
||||
debug("find %s section at %u %u\n", section, (grub_uint32_t)offset, len);
|
||||
break;
|
||||
}
|
||||
t = (Elf64_Shdr *)((char *)t + e->e_shentsize);
|
||||
@@ -634,11 +610,11 @@ grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc,
|
||||
|
||||
for (t = h, i = 0; i < e->e_shnum; i++)
|
||||
{
|
||||
if (grub_strcmp(str + t->sh_name, ".data") == 0)
|
||||
if (grub_strcmp(str + t->sh_name, section) == 0)
|
||||
{
|
||||
offset = t->sh_offset;
|
||||
len = t->sh_size;
|
||||
debug("find .data section at %u %u\n", (grub_uint32_t)offset, len);
|
||||
debug("find %s section at %u %u\n", section, (grub_uint32_t)offset, len);
|
||||
break;
|
||||
}
|
||||
t = (Elf32_Shdr *)((char *)t + e->e_shentsize);
|
||||
@@ -647,7 +623,7 @@ grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc,
|
||||
|
||||
if (offset == 0 || len == 0)
|
||||
{
|
||||
debug(".data section not found %s\n", args[0]);
|
||||
debug("%s section not found\n", section);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -672,21 +648,64 @@ grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ver[0])
|
||||
{
|
||||
k = (int)grub_strtoul(ver, NULL, 10);
|
||||
debug("freebsd version:<%s> <%d.x>\n", ver, k);
|
||||
debug("%s freebsd version:<%s> <%d.x>\n", section, ver, k);
|
||||
grub_snprintf(ver, sizeof(ver), "%d.x", k);
|
||||
ventoy_set_env(args[2], ver);
|
||||
ventoy_set_env(env, ver);
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("freebsd version:<%s>\n", "NOT FOUND");
|
||||
debug("%s freebsd version:<%s>\n", section, "NOT FOUND");
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
out:
|
||||
grub_check_free(str);
|
||||
grub_check_free(hdr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_unix_freebsd_ver_elf(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int ret = 0;
|
||||
int bit64 = 0;
|
||||
char *data = NULL;
|
||||
grub_elf_t elf = NULL;
|
||||
|
||||
(void)ctxt;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
debug("Invalid argc %d\n", argc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
data = grub_zalloc(8192);
|
||||
if (!data)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
elf = grub_elf_open(args[0], GRUB_FILE_TYPE_LINUX_INITRD);
|
||||
if (!elf)
|
||||
{
|
||||
debug("Failed to open file %s\n", args[0]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
bit64 = (args[1][0] == '6') ? 1 : 0;
|
||||
|
||||
ret = ventoy_freebsd_ver_elf(bit64, elf, ".data", args[2], data);
|
||||
if (ret != 0)
|
||||
{
|
||||
ret = ventoy_freebsd_ver_elf(bit64, elf, ".rodata", args[2], data);
|
||||
}
|
||||
|
||||
out:
|
||||
grub_check_free(data);
|
||||
check_free(elf, grub_elf_close);
|
||||
|
||||
|
||||
@@ -17,5 +17,10 @@
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
if $GREP -q 'rdinit=/vtoy/vtoy' /proc/cmdline; then
|
||||
echo "fix rdinit" >> $VTLOG
|
||||
$SED "/switch_root.*\/mnt\/.installer-mp/i\ sh $VTOY_PATH/hook/debian/pve-wa.sh /mnt/.installer-mp/sbin/unconfigured.sh" -i /init
|
||||
fi
|
||||
|
||||
$SED "/\/sys\/block\/hd\*/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/pve-disk.sh" -i /init
|
||||
$SED "s#/sys/block/hd\*#/sys/block/dm* /sys/block/hd*#" -i /init
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
script=$1
|
||||
tmpscript=${script}.tmp
|
||||
|
||||
LINE=$(grep -n 'proc.*proc.*proc' $script | awk -F':' '{print $1}')
|
||||
|
||||
sed -n "1,${LINE}p" $script >> $tmpscript
|
||||
|
||||
echo "if grep -q 'rdinit=/vtoy/vtoy' /proc/cmdline; then" >> $tmpscript
|
||||
echo " sed 's#rdinit=/vtoy/vtoy##g' /proc/cmdline > /etc/cmdline" >> $tmpscript
|
||||
echo " mount --bind /etc/cmdline /proc/cmdline" >> $tmpscript
|
||||
echo "fi" >> $tmpscript
|
||||
|
||||
|
||||
let LINE++
|
||||
sed -n "${LINE},\$p" $script >> $tmpscript
|
||||
|
||||
cat $tmpscript > $script
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
$CAT /proc/cmdline > /ventoy/cmdline
|
||||
$SED 's#live-media=[^ ]*#live-media=/dev/mapper/ventoy#g' -i /ventoy/cmdline
|
||||
|
||||
if [ -e /init ] && $GREP -q '^mountroot$' /init; then
|
||||
echo "Here before mountroot ..." >> $VTLOG
|
||||
@@ -25,6 +27,8 @@ if [ -e /init ] && $GREP -q '^mountroot$' /init; then
|
||||
$SED "/^mountroot$/i\\export LIVEMEDIA=/dev/mapper/ventoy" -i /init
|
||||
$SED "/^mountroot$/i\\export LIVE_MEDIA=/dev/mapper/ventoy" -i /init
|
||||
|
||||
$SED "/mount *[-]t *proc/a\\mount --bind /ventoy/cmdline /proc/cmdline" -i /init
|
||||
|
||||
if $GREP -q 'live-media=' /proc/cmdline; then
|
||||
if [ -f /scripts/casper ] && $GREP -q '^ *LIVEMEDIA=' /scripts/casper; then
|
||||
$SED "s#^ *LIVEMEDIA=.*#LIVEMEDIA=/dev/mapper/ventoy#" -i /scripts/casper
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/ventoy/busybox/sh
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
vtlog "######### $0 $* ############"
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vtlog "vtdiskname=$vtdiskname"
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
# OK finish
|
||||
set_ventoy_hook_finish
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
function ft_mountCdromDir()
|
||||
{
|
||||
/ventoy/busybox/sh /ventoy/hook/euleros/disk_mount_hook.sh
|
||||
ft_mountCdromDirXX "$@"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. $VTOY_PATH/hook/ventoy-os-lib.sh
|
||||
|
||||
TRANSFILE=/usr/Euler/project/load/filetransfer.sh
|
||||
|
||||
LINE=$($GREP -n 'function ft_mountCdromDir' $TRANSFILE | $AWK -F':' '{print $1}')
|
||||
|
||||
echo "LINE=$LINE" >> $VTLOG
|
||||
|
||||
$SED 's#FT_SR_DEV=.*#FT_SR_DEV=/dev/mapper/ventoy#g' -i $TRANSFILE
|
||||
$SED 's/function ft_mountCdromDir/function ft_mountCdromDirXX/' -i $TRANSFILE
|
||||
|
||||
let LINE--
|
||||
$SED -n "1,${LINE}p" $TRANSFILE >> /ventoy/filetransfer.sh
|
||||
|
||||
$CAT $VTOY_PATH/hook/euleros/hook_func.sh >> /ventoy/filetransfer.sh
|
||||
|
||||
let LINE++
|
||||
$SED -n "${LINE},\$p" $TRANSFILE >> /ventoy/filetransfer.sh
|
||||
|
||||
$BUSYBOX_PATH/mv /ventoy/filetransfer.sh $TRANSFILE
|
||||
|
||||
#fix the euler os shell script
|
||||
$SED 's/-z ${harddisk_disk_list}/-z "${harddisk_disk_list}"/' -i /usr/Euler/project/disk/disk_tool.sh
|
||||
@@ -100,7 +100,11 @@ ventoy_get_os_type() {
|
||||
echo 'rhel7'; return
|
||||
|
||||
elif $GREP -q 'euleros' /proc/version; then
|
||||
if [ -d /usr/Euler/project/init ]; then
|
||||
echo 'euleros'; return
|
||||
else
|
||||
echo 'rhel7'; return
|
||||
fi
|
||||
|
||||
# SUSE
|
||||
elif $GREP -q 'SUSE' /proc/version; then
|
||||
@@ -436,7 +440,11 @@ fi
|
||||
# #
|
||||
####################################################################
|
||||
if [ -f "/live_injection_7ed136ec_7a61_4b54_adc3_ae494d5106ea/hook.sh" ]; then
|
||||
$BUSYBOX_PATH/sh "/live_injection_7ed136ec_7a61_4b54_adc3_ae494d5106ea/hook.sh" $VTOS
|
||||
echo "==== Begin Call live injection hook.sh $VTOS" >> $VTLOG
|
||||
$BUSYBOX_PATH/sh "/live_injection_7ed136ec_7a61_4b54_adc3_ae494d5106ea/hook.sh" $VTOS >>$VTLOG 2>&1
|
||||
echo "==== Finish Call live injection hook.sh $VTOS" >> $VTLOG
|
||||
else
|
||||
echo "No live injection" >> $VTLOG
|
||||
fi
|
||||
|
||||
|
||||
|
||||
+1
-10
@@ -1,7 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
OLDDIR=$(pwd)
|
||||
|
||||
if ! [ -f ./tool/ventoy_lib.sh ]; then
|
||||
if [ -f ${0%Ventoy2Disk.sh}/tool/ventoy_lib.sh ]; then
|
||||
cd ${0%Ventoy2Disk.sh}
|
||||
@@ -21,7 +19,7 @@ elif uname -m | grep -E -q 'mips64'; then
|
||||
else
|
||||
export TOOLDIR=i386
|
||||
fi
|
||||
export PATH="$OLDDIR/tool/$TOOLDIR:$PATH"
|
||||
export PATH="$(pwd)/tool/$TOOLDIR:$PATH"
|
||||
|
||||
|
||||
echo ''
|
||||
@@ -88,10 +86,3 @@ if [ -f /bin/bash ]; then
|
||||
else
|
||||
ash ./tool/VentoyWorker.sh $*
|
||||
fi
|
||||
|
||||
if [ -n "$OLDDIR" ]; then
|
||||
CURDIR=$(pwd)
|
||||
if [ "$CURDIR" != "$OLDDIR" ]; then
|
||||
cd "$OLDDIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
+7
-20
@@ -34,20 +34,6 @@ function ventoy_debug_pause {
|
||||
}
|
||||
|
||||
|
||||
function ventoy_max_resolution {
|
||||
#Skip this for VirtualBox
|
||||
smbios -t 1 -s 0x05 --set=system_product;
|
||||
if vt_str_casebegin "$system_product" "VirtualBox"; then
|
||||
return
|
||||
fi
|
||||
|
||||
vt_enum_video_mode
|
||||
vt_get_video_mode 0 vtCurMode
|
||||
terminal_output console
|
||||
set gfxmode=$vtCurMode
|
||||
terminal_output gfxterm
|
||||
}
|
||||
|
||||
function ventoy_cli_console {
|
||||
if [ -z "$vtoy_display_mode" ]; then
|
||||
terminal_output console
|
||||
@@ -503,19 +489,19 @@ function ventoy_freebsd_proc {
|
||||
ventoy_get_truenas_ver "$1" "${chosen_path}"
|
||||
elif vt_strstr "$vt_volume_id" "FURYBSD"; then
|
||||
ventoy_get_furybsd_ver "$1" "${chosen_path}"
|
||||
elif regexp --set 1:vtBsdVerNum "^(15|14|13|12|11|10|9)_[0-9]" "$vt_volume_id"; then
|
||||
elif regexp --set 1:vtBsdVerNum "^(1[0-9]|9)_[0-9]" "$vt_volume_id"; then
|
||||
set vt_freebsd_ver=${vtBsdVerNum}.x
|
||||
elif [ -d (loop)/usr/midnightbsd-dist ]; then
|
||||
ventoy_get_midnightbsd_ver "$1" "${chosen_path}"
|
||||
set vtFreeBsdDistro=MidnightBSD
|
||||
elif [ -e (loop)/bin/freebsd-version ]; then
|
||||
vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver
|
||||
if regexp --set 1:vtBsdVerNum "\"(15|14|13|12|11|10|9)\.[0-9]-" "$vt_userland_ver"; then
|
||||
if regexp --set 1:vtBsdVerNum "\"(1[0-9]|9)\.[0-9]-" "$vt_userland_ver"; then
|
||||
set vt_freebsd_ver=${vtBsdVerNum}.x
|
||||
fi
|
||||
elif [ -e (loop)/README.TXT ]; then
|
||||
vt_1st_line (loop)/README.TXT vt_freebsd_line1
|
||||
if regexp --set 1:vtBsdVerNum "FreeBSD (15|14|13|12|11|10|9)\.[0-9]-" "$vt_freebsd_line1"; then
|
||||
if regexp --set 1:vtBsdVerNum "FreeBSD (1[0-9]|9)\.[0-9]-" "$vt_freebsd_line1"; then
|
||||
set vt_freebsd_ver=${vtBsdVerNum}.x
|
||||
fi
|
||||
elif vt_strstr "${chosen_path}" "MidnightBSD"; then
|
||||
@@ -545,7 +531,7 @@ function ventoy_freebsd_proc {
|
||||
fi
|
||||
|
||||
if [ "$vt_freebsd_ver" = "xx" ]; then
|
||||
set vt_freebsd_ver=14.x
|
||||
set vt_freebsd_ver=15.x
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -662,7 +648,6 @@ function uefi_windows_menu_func {
|
||||
|
||||
if [ -n "$vtoy_chain_mem_addr" ]; then
|
||||
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
|
||||
ventoy_max_resolution
|
||||
chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} iso_${ventoy_fs_probe} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
|
||||
boot
|
||||
else
|
||||
@@ -747,6 +732,8 @@ function uefi_linux_menu_func {
|
||||
vt_add_replace_file $vtindex "arch\\boot\\x86_64\\initramfs-linux.img"
|
||||
elif [ -f (loop)/boot/initramfs_x86_64.img ]; then
|
||||
vt_add_replace_file $vtindex "boot\\initramfs_x86_64.img"
|
||||
elif [ -f (loop)/arch/boot/x86_64/initramfs-linux-aegis-offensive.img ]; then
|
||||
vt_add_replace_file $vtindex "arch\\boot\\x86_64\\initramfs-linux-aegis-offensive.img"
|
||||
fi
|
||||
elif [ -d (loop)/blackarch ]; then
|
||||
if [ -f (loop)/blackarch/boot/x86_64/archiso.img ]; then
|
||||
@@ -2452,7 +2439,7 @@ function mimg_common_menuentry {
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
set VENTOY_VERSION="1.1.16"
|
||||
set VENTOY_VERSION="1.1.17"
|
||||
|
||||
#ACPI not compatible with Window7/8, so disable by default
|
||||
set VTOY_PARAM_NO_ACPI=1
|
||||
|
||||
@@ -28,11 +28,14 @@ menuentry "$VTLANG_HWINFO" --class=debug_hwinfo --class=F5tool {
|
||||
echo "Platform $grub_cpu-$grub_platform"
|
||||
if [ "$grub_platform" != "pc" ]; then
|
||||
echo "UEFI Version $grub_uefi_version"
|
||||
echo "PI Version $grub_pi_version"
|
||||
if vt_check_secureboot_var; then
|
||||
echo "Secure Boot Enabled"
|
||||
else
|
||||
echo "Secure Boot Disabled"
|
||||
fi
|
||||
|
||||
vt_sbinfo
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
@@ -186,7 +186,7 @@ if [ "$MODE" = "install" -a -z "$NONDESTRUCTIVE" ]; then
|
||||
else
|
||||
if parted -v > /dev/null 2>&1; then
|
||||
PARTTOOL='parted'
|
||||
elif fdisk -v >/dev/null 2>&1; then
|
||||
elif command -v fdisk > /dev/null 2>&1; then
|
||||
PARTTOOL='fdisk'
|
||||
else
|
||||
vterr "Both parted and fdisk are not found in the system, Ventoy can't create new partitions."
|
||||
|
||||
+18
-7
@@ -12,7 +12,6 @@ if [ "$VENTOY_CERT_PASS" = "YES" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
SBAT_VER=1
|
||||
sign_efi() {
|
||||
efi=$1
|
||||
|
||||
@@ -32,10 +31,6 @@ sign_efi() {
|
||||
mv ${efi}.unxz ${efi}
|
||||
fi
|
||||
|
||||
sbstr=$(printf "%08x" $SBAT_VER)
|
||||
echo -en "\x8a\x06\x55\xf7\x4f\xe0\x2b\x45\x9d\x6d\x7c\x55\x96\xb3\xc0\x7d\x${sbstr:6:2}\x${sbstr:4:2}\x${sbstr:2:2}\x${sbstr:0:2}" | \
|
||||
dd bs=1 count=20 of=${efi} seek=40 conv=notrunc status=none
|
||||
|
||||
rm -f "${efi}.signed"
|
||||
if [ "$VENTOY_CERT_PASS" = "YES" ]; then
|
||||
expect -f ./sign_with_pass.exp "$KEY_PASS" "$VENTOY_CERT_KEY" "$VENTOY_CERT_PEM" "${efi}" "${efi}.signed" >/dev/null 2>&1
|
||||
@@ -52,7 +47,7 @@ sign_efi() {
|
||||
mv "${efi}.signed" "$efi"
|
||||
fi
|
||||
else
|
||||
echo "### %-64s failed\n" "$efi"
|
||||
printf "### %-64s failed\n" "$efi"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -191,7 +186,6 @@ cp -a ./tool/create_ventoy_iso_part_dm.sh $tmpmnt/tool/
|
||||
rm -f $tmpmnt/grub/i386-pc/*.img
|
||||
|
||||
|
||||
sign_efi $tmpmnt/EFI/BOOT/fbx64.efi
|
||||
sign_efi $tmpmnt/EFI/BOOT/fbia32.efi
|
||||
sign_efi $tmpmnt/EFI/BOOT/fbaa64.efi
|
||||
sign_efi $tmpmnt/EFI/BOOT/grubx64_real.efi
|
||||
@@ -211,6 +205,23 @@ sign_efi $tmpmnt/ventoy/vtoyutil_aa64.efi
|
||||
sign_efi $tmpmnt/ventoy/wimboot.i386.efi.xz
|
||||
sign_efi $tmpmnt/ventoy/wimboot.x86_64.xz
|
||||
|
||||
#inject Ventoy Grub sign sha256 value into VtoyShim
|
||||
grub_sha256=$(sha256sum $tmpmnt/EFI/BOOT/grubx64_real.efi | awk '{print $1}')
|
||||
magic_cnt=$(hexdump -C $tmpmnt/EFI/BOOT/fbx64.efi | grep '26 26 26 26 26 26 26 26' | wc -l)
|
||||
if [ $magic_cnt -ne 1 ]; then
|
||||
echo "hash magic duplicate"
|
||||
exit 1
|
||||
fi
|
||||
magic_off_hex=$(hexdump -C $tmpmnt/EFI/BOOT/fbx64.efi | grep '26 26 26 26 26 26 26 26' | awk '{print $1}')
|
||||
magic_off=$(printf '%u' "0x${magic_off_hex}")
|
||||
|
||||
echo_cmd=$(echo $grub_sha256 | sed 's/\(..\)/\\x\1/g')
|
||||
|
||||
echo Ventoy Grub hash $grub_sha256
|
||||
echo -en "$echo_cmd" | dd bs=1 count=32 of=$tmpmnt/EFI/BOOT/fbx64.efi seek=$magic_off conv=notrunc status=none
|
||||
|
||||
sign_efi $tmpmnt/EFI/BOOT/fbx64.efi
|
||||
|
||||
|
||||
umount $tmpmnt && rm -rf $tmpmnt
|
||||
|
||||
|
||||
@@ -198,13 +198,13 @@
|
||||
"name":"Korean (한국어)",
|
||||
"FontFamily":"Courier New",
|
||||
"FontSize":16,
|
||||
"Author":"VenusGirl",
|
||||
"Author":"VenusGirl, HYB1022",
|
||||
|
||||
"STR_ERROR":"오류",
|
||||
"STR_WARNING":"경고",
|
||||
"STR_INFO":"정보",
|
||||
"STR_INCORRECT_DIR":"올바른 디렉터리에서 실행하십시오!",
|
||||
"STR_INCORRECT_TREE_DIR":"여기서 프로그램 (INSTALL 디렉터리)을 실행하지 말고 설치 패키지를 다운로드하여 압축을 푼 후 그곳에서 실행해 주십시오.",
|
||||
"STR_INCORRECT_DIR":"올바른 파일 경로에서 실행하십시오!",
|
||||
"STR_INCORRECT_TREE_DIR":"여기(INSTALL 경로)서 프로그램을 실행하지 말고 설치 패키지를 다운로드하여 압축을 푼 후 그곳에서 실행해 주십시오.",
|
||||
"STR_DEVICE":"장치",
|
||||
"STR_LOCAL_VER":"패키지의 Ventoy 버전",
|
||||
"STR_DISK_VER":"장치 내부의 Ventoy 버전",
|
||||
@@ -216,10 +216,10 @@
|
||||
"STR_INSTALL_TIP2":"디스크가 포맷되고 모든 데이터가 손실됩니다.#@계속하시겠습니까? (다시 확인)",
|
||||
"STR_INSTALL_SUCCESS":"축하합니다!#@Ventoy가 장치에 성공적으로 설치되었습니다.",
|
||||
"STR_INSTALL_FAILED":"설치 중 오류가 발생했습니다. USB를 다시 삽입하고 다시 시도할 수 있습니다. 자세한 내용은 log.txt를 확인하십시오.",
|
||||
"STR_UPDATE_SUCCESS":"축하합니다!#@Ventoy가 장치에 성공적으로 업데이트되었습니다.",
|
||||
"STR_UPDATE_SUCCESS":"축하합니다! 장치에 설치된#@Ventoy가 성공적으로 업데이트되었습니다.",
|
||||
"STR_UPDATE_FAILED":"업데이트 중에 오류가 발생했습니다. USB를 다시 삽입하고 다시 시도할 수 있습니다. 자세한 내용은 log.txt를 확인하십시오.",
|
||||
"STR_WAIT_PROCESS":"현재 작업이 실행 중입니다. 기다려 주십시오...",
|
||||
"STR_MENU_OPTION":"옵션",
|
||||
"STR_MENU_OPTION":"설정",
|
||||
"STR_MENU_SECURE_BOOT":"보안 부트 (Secure Boot) 지원",
|
||||
"STR_MENU_PART_CFG":"파티션 구성",
|
||||
"STR_BTN_OK":"확인",
|
||||
|
||||
@@ -228,6 +228,7 @@ DRESULT disk_write (
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
buff += 512;
|
||||
sector++;
|
||||
count--;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user