IA32 ARM64 support

This commit is contained in:
longpanda
2020-12-12 07:56:52 +08:00
parent 2936666a78
commit ebaa4d954a
478 changed files with 10301 additions and 748 deletions

View File

@@ -798,10 +798,11 @@ static int VentoyFatDiskRead(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
}
int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSector, CHAR *VerBuf, size_t BufLen)
int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSector, CHAR *VerBuf, size_t BufLen, BOOL *pSecureBoot)
{
int rc = 0;
HANDLE hDrive;
void *flfile;
hDrive = GetPhysicalHandle(pDriveInfo->PhyDrive, FALSE, FALSE, FALSE);
if (hDrive == INVALID_HANDLE_VALUE)
@@ -831,6 +832,13 @@ int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSe
if (rc == 0)
{
Log("VentoyVerInPhyDrive %d is <%s>...", pDriveInfo->PhyDrive, VerBuf);
flfile = fl_fopen("/EFI/BOOT/grubx64_real.efi", "rb");
if (flfile)
{
*pSecureBoot = TRUE;
fl_fclose(flfile);
}
}
fl_shutdown();
@@ -962,6 +970,50 @@ int VentoyProcSecureBoot(BOOL SecureBoot)
free(filebuf);
}
}
file = fl_fopen("/EFI/BOOT/grubia32_real.efi", "rb");
Log("Open ventoy efi file %p ", file);
if (file)
{
fl_fseek(file, 0, SEEK_END);
size = (int)fl_ftell(file);
fl_fseek(file, 0, SEEK_SET);
Log("ventoy efi file size %d ...", size);
filebuf = (char *)malloc(size);
if (filebuf)
{
fl_fread(filebuf, 1, size, file);
}
fl_fclose(file);
Log("Now delete all efi files ...");
fl_remove("/EFI/BOOT/BOOTIA32.EFI");
fl_remove("/EFI/BOOT/grubia32.efi");
fl_remove("/EFI/BOOT/grubia32_real.efi");
fl_remove("/EFI/BOOT/mmia32.efi");
file = fl_fopen("/EFI/BOOT/BOOTIA32.EFI", "wb");
Log("Open bootia32 efi file %p ", file);
if (file)
{
if (filebuf)
{
fl_fwrite(filebuf, 1, size, file);
}
fl_fflush(file);
fl_fclose(file);
}
if (filebuf)
{
free(filebuf);
}
}
}
else
{
@@ -1627,6 +1679,7 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
}
Log("Write GPT Info OK ...");
memcpy(&(pPhyDrive->MBR), &MBR, 512);
}
else
{
@@ -1637,8 +1690,8 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
goto End;
}
Log("Write MBR OK ...");
memcpy(&(pPhyDrive->MBR), &MBR, 512);
}
//Refresh Drive Layout
DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &dwSize, NULL);
@@ -1719,6 +1772,7 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
MBR_HEAD BootImg;
MBR_HEAD MBR;
VTOY_GPT_INFO *pGptInfo = NULL;
UINT8 ReservedData[4096];
Log("UpdateVentoy2PhyDrive %s PhyDrive%d <<%s %s %dGB>>",
pPhyDrive->PartStyle ? "GPT" : "MBR", pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId,
@@ -1771,6 +1825,10 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
Log("MBR Reserved Disk Space:%llu MB", (ULONGLONG)ReservedMB);
}
//Read Reserved Data
SetFilePointer(hDrive, 512 * 2040, NULL, FILE_BEGIN);
ReadFile(hDrive, ReservedData, sizeof(ReservedData), &dwSize, NULL);
GetLettersBelongPhyDrive(pPhyDrive->PhyDrive, DriveLetters, sizeof(DriveLetters));
if (DriveLetters[0] == 0)
@@ -1895,6 +1953,11 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
goto End;
}
//write reserved data
SetFilePointer(hDrive, 512 * 2040, NULL, FILE_BEGIN);
bRet = WriteFile(hDrive, ReservedData, sizeof(ReservedData), &dwSize, NULL);
Log("Write resv data ret:%u dwSize:%u Error:%u", bRet, dwSize, LASTERR);
// Boot Image
VentoyGetLocalBootImg(&BootImg);

View File

@@ -231,13 +231,6 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
CurDrive->Id = -1;
memset(CurDrive->DriveLetters, 0, sizeof(CurDrive->DriveLetters));
// Too big for MBR
if (CurDrive->SizeInBytes > 2199023255552ULL)
{
Log("<%s %s> is filtered for too big for MBR.", CurDrive->VendorId, CurDrive->ProductId);
continue;
}
if (g_FilterRemovable && (!CurDrive->RemovableMedia))
{
Log("<%s %s> is filtered for not removable.", CurDrive->VendorId, CurDrive->ProductId);
@@ -266,8 +259,10 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
if (IsVentoyPhyDrive(CurDrive->PhyDrive, CurDrive->SizeInBytes, &MBR, &Part2StartSector))
{
memcpy(&(CurDrive->MBR), &MBR, sizeof(MBR));
CurDrive->PartStyle = (MBR.PartTbl[0].FsFlag == 0xEE) ? 1 : 0;
GetVentoyVerInPhyDrive(CurDrive, Part2StartSector, CurDrive->VentoyVersion, sizeof(CurDrive->VentoyVersion));
GetVentoyVerInPhyDrive(CurDrive, Part2StartSector, CurDrive->VentoyVersion, sizeof(CurDrive->VentoyVersion), &(CurDrive->SecureBootSupport));
Log("PhyDrive %d is Ventoy Disk ver:%s SecureBoot:%u", CurDrive->PhyDrive, CurDrive->VentoyVersion, CurDrive->SecureBootSupport);
}
}

View File

@@ -116,6 +116,18 @@ typedef struct VTOY_GPT_INFO
VTOY_GPT_PART_TBL PartTbl[128];
}VTOY_GPT_INFO;
typedef struct ventoy_secure_data
{
UINT8 magic1[16]; /* VENTOY_GUID */
UINT8 diskuuid[16];
UINT8 Checksum[16];
UINT8 adminSHA256[32];
UINT8 reserved[4000];
UINT8 magic2[16]; /* VENTOY_GUID */
}ventoy_secure_data;
#pragma pack()
#define VENTOY_MAX_PHY_DRIVE 128
@@ -138,6 +150,8 @@ typedef struct PHY_DRIVE_INFO
CHAR VentoyVersion[32];
BOOL SecureBootSupport;
MBR_HEAD MBR;
}PHY_DRIVE_INFO;
typedef enum PROGRESS_POINT
@@ -186,7 +200,7 @@ int GetRegDwordValue(HKEY Key, LPCSTR SubKey, LPCSTR ValueName, DWORD *pValue);
int GetPhysicalDriveCount(void);
int GetAllPhysicalDriveInfo(PHY_DRIVE_INFO *pDriveList, DWORD *pDriveCount);
int GetPhyDriveByLogicalDrive(int DriveLetter);
int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSector, CHAR *VerBuf, size_t BufLen);
int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSector, CHAR *VerBuf, size_t BufLen, BOOL *pSecureBoot);
int Ventoy2DiskInit(void);
int Ventoy2DiskDestroy(void);
PHY_DRIVE_INFO * GetPhyDriveInfoById(int Id);

Binary file not shown.