Commit 1cbe4c81 authored by longpanda's avatar longpanda
Browse files

1.0.14 release

parent 42990058
No preview for this file type
......@@ -1057,6 +1057,28 @@ static __asmcall void int13 ( struct i386_all_regs *ix86 ) {
return;
}
if (VENTOY_BOOT_FIXBIN_DRIVE == bios_drive && INT13_READ_SECTORS == command)
{
/* read sector 0 0x80 */
if (ix86->regs.dh == 0 && (ix86->regs.cl & 0x3f) == 1 && ix86->regs.al == 1)
{
userptr_t buffer;
buffer = real_to_user(ix86->segs.es, ix86->regs.bx);
if (buffer)
{
memset((void *)buffer, 0, 512);
}
ix86->regs.dl = 0x80;
ix86->regs.ah = 0;
/* Set OF to indicate to wrapper not to chain this call */
ix86->flags |= OF;
return;
}
}
// drive swap
if (g_drive_map1 >= 0x80 && g_drive_map2 >= 0x80)
{
......
......@@ -92,7 +92,7 @@ struct san_device {
uint8_t boot_catalog_sector[2048];
/** SAN paths */
struct san_path path[0];
struct san_path path[0];
};
/** SAN device flags */
......
......@@ -170,6 +170,7 @@ typedef struct ventoy_sector_flag
}ventoy_sector_flag;
#define VENTOY_BIOS_FAKE_DRIVE 0xFE
#define VENTOY_BOOT_FIXBIN_DRIVE 0xFD
extern int g_debug;
extern char *g_cmdline_copy;
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -51,12 +51,19 @@ typedef enum STR_ID
STR_MENU_OPTION,//19
STR_MENU_SECURE_BOOT,//20
STR_MENU_PART_CFG,//21
STR_BTN_OK,//22
STR_BTN_CANCEL,//23
STR_PRESERVE_SPACE,//24
STR_SPACE_VAL_INVALID,//25
STR_ID_MAX
}STR_ID;
extern BOOL g_SecureBoot;
#define VTOY_MENU_SECURE_BOOT 0xA000
#define VTOY_MENU_PART_CFG 0xA001
#define VTOY_MENU_LANGUAGE_BEGIN 0xB000
......
B/******************************************************************************
......@@ -304,7 +304,7 @@ static DWORD GetVentoyVolumeName(int PhyDrive, UINT32 StartSectorId, CHAR *NameB
PartOffset = 512ULL * StartSectorId;
Log("GetVentoyVolumeName PhyDrive %d PartOffset:%llu", PhyDrive, (ULONGLONG)PartOffset);
Log("GetVentoyVolumeName PhyDrive %d SectorStart:%u PartOffset:%llu", PhyDrive, StartSectorId, (ULONGLONG)PartOffset);
hVolume = FindFirstVolumeA(VolumeName, sizeof(VolumeName));
if (hVolume == INVALID_HANDLE_VALUE)
......@@ -798,7 +798,7 @@ static int VentoyFatDiskRead(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
}
int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, CHAR *VerBuf, size_t BufLen)
int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, MBR_HEAD *pMBR, CHAR *VerBuf, size_t BufLen)
{
int rc = 0;
HANDLE hDrive;
......@@ -810,7 +810,7 @@ int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, CHAR *VerBuf, size_
}
g_FatPhyDrive = hDrive;
g_Part2StartSec = (pDriveInfo->SizeInBytes - VENTOY_EFI_PART_SIZE) / 512;
g_Part2StartSec = pMBR->PartTbl[1].StartSectorId;
Log("Parse FAT fs...");
......@@ -1033,8 +1033,9 @@ static int FormatPart2Fat(HANDLE hDrive, UINT64 StartSectorId)
BOOL bRet;
unsigned char *data = NULL;
LARGE_INTEGER liCurrentPosition;
LARGE_INTEGER liNewPosition;
Log("FormatPart2Fat ...");
Log("FormatPart2Fat %llu...", StartSectorId);
rc = ReadWholeFileToBuf(VENTOY_FILE_DISK_IMG, 0, (void **)&data, &len);
if (rc)
......@@ -1044,7 +1045,9 @@ static int FormatPart2Fat(HANDLE hDrive, UINT64 StartSectorId)
}
liCurrentPosition.QuadPart = StartSectorId * 512;
SetFilePointerEx(hDrive, liCurrentPosition, &liCurrentPosition, FILE_BEGIN);
SetFilePointerEx(hDrive, liCurrentPosition, &liNewPosition, FILE_BEGIN);
Log("Set file pointer: %llu New pointer:%llu", liCurrentPosition.QuadPart, liNewPosition.QuadPart);
memset(g_part_img_buf, 0, sizeof(g_part_img_buf));
......@@ -1063,7 +1066,7 @@ static int FormatPart2Fat(HANDLE hDrive, UINT64 StartSectorId)
for (i = 0; i < VENTOY_EFI_PART_SIZE / SIZE_1MB; i++)
{
dwSize = 0;
bRet = WriteFile(hDrive, g_part_img_buf[0] + i * SIZE_1MB, SIZE_1MB, &dwSize, NULL);
bRet = WriteFile(hDrive, g_part_img_buf[0] + i * SIZE_1MB, SIZE_1MB, &dwSize, NULL);
Log("Write part data bRet:%u dwSize:%u code:%u", bRet, dwSize, LASTERR);
if (!bRet)
......@@ -1425,11 +1428,10 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
CHAR DriveName[] = "?:\\";
CHAR DriveLetters[MAX_PATH] = { 0 };
UINT32 StartSector;
UINT64 ReservedMB = 0;
MBR_HEAD BootImg;
MBR_HEAD MBR;
StartSector = (UINT32)(pPhyDrive->SizeInBytes / 512 - VENTOY_EFI_PART_SIZE / 512);
Log("UpdateVentoy2PhyDrive PhyDrive%d <<%s %s %dGB>>",
pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId,
GetHumanReadableGBSize(pPhyDrive->SizeInBytes));
......@@ -1446,8 +1448,15 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
}
// Read MBR
SetFilePointer(hDrive, 0, NULL, FILE_BEGIN);
ReadFile(hDrive, &MBR, sizeof(MBR), &dwSize, NULL);
StartSector = MBR.PartTbl[1].StartSectorId;
Log("StartSector in PartTbl:%u", StartSector);
ReservedMB = (pPhyDrive->SizeInBytes / 512 - (StartSector + VENTOY_EFI_PART_SIZE / 512)) / 2048;
Log("Reserved Disk Space:%u MB", ReservedMB);
GetLettersBelongPhyDrive(pPhyDrive->PhyDrive, DriveLetters, sizeof(DriveLetters));
if (DriveLetters[0] == 0)
......
......@@ -427,10 +427,12 @@ static int VentoyFillLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT
int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR)
{
GUID Guid;
int ReservedValue;
UINT32 DiskSignature;
UINT32 DiskSectorCount;
UINT32 PartSectorCount;
UINT32 PartStartSector;
UINT32 ReservedSector;
VentoyGetLocalBootImg(pMBR);
......@@ -444,9 +446,21 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR)
DiskSectorCount = (UINT32)(DiskSizeBytes / 512);
ReservedValue = GetReservedSpaceInMB();
if (ReservedValue <= 0)
{
ReservedSector = 0;
}
else
{
ReservedSector = (UINT32)(ReservedValue * 2048);
}
Log("ReservedSector: %u", ReservedSector);
//Part1
PartStartSector = VENTOY_PART1_START_SECTOR;
PartSectorCount = DiskSectorCount - VENTOY_EFI_PART_SIZE / 512 - PartStartSector;
PartSectorCount = DiskSectorCount - ReservedSector - VENTOY_EFI_PART_SIZE / 512 - PartStartSector;
VentoyFillLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl);
pMBR->PartTbl[0].Active = 0x80; // bootable
......
......@@ -70,7 +70,7 @@ int ParseCmdLineOption(LPSTR lpCmdLine)
return 0;
}
static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes)
static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR)
{
int i;
BOOL bRet;
......@@ -121,30 +121,24 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes)
Log("PartTbl.EndCylinder = %u", MBR.PartTbl[i].EndCylinder);
}
if (MBR.PartTbl[2].SectorCount > 0 || MBR.PartTbl[3].SectorCount > 0)
{
Log("Part3 Part4 are not empty");
return FALSE;
}
PartStartSector = 2048;
PartSectorCount = (UINT32)((SizeBytes - VENTOY_EFI_PART_SIZE - SIZE_1MB) / 512);
if (MBR.PartTbl[0].StartSectorId != PartStartSector ||
MBR.PartTbl[0].SectorCount != PartSectorCount)
if (MBR.PartTbl[0].StartSectorId != 2048)
{
Log("Part1 not match %u %u", PartStartSector, PartSectorCount);
Log("Part1 not match %u", MBR.PartTbl[0].StartSectorId);
return FALSE;
}
PartStartSector = (UINT32)((SizeBytes - VENTOY_EFI_PART_SIZE) / 512);
PartStartSector = MBR.PartTbl[0].StartSectorId + MBR.PartTbl[0].SectorCount;
PartSectorCount = VENTOY_EFI_PART_SIZE / 512;
if (MBR.PartTbl[1].FsFlag != 0xEF ||
MBR.PartTbl[1].StartSectorId != PartStartSector ||
MBR.PartTbl[1].SectorCount != PartSectorCount)
{
Log("Part2 not match %u %u", PartStartSector, PartSectorCount);
Log("Part2 not match [0x%x 0x%x] [%u %u] [%u %u]",
MBR.PartTbl[1].FsFlag, 0xEF,
MBR.PartTbl[1].StartSectorId, PartStartSector,
MBR.PartTbl[1].SectorCount, PartSectorCount);
return FALSE;
}
......@@ -154,6 +148,7 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes)
return FALSE;
}
memcpy(pMBR, &MBR, sizeof(MBR_HEAD));
Log("PhysicalDrive%d is ventoy disk", PhyDrive);
return TRUE;
}
......@@ -167,6 +162,7 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
int Id = 0;
int LetterCount = 0;
PHY_DRIVE_INFO *CurDrive;
MBR_HEAD MBR;
int LogLetter[VENTOY_MAX_PHY_DRIVE];
int PhyDriveId[VENTOY_MAX_PHY_DRIVE];
......@@ -221,9 +217,9 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
}
}
if (IsVentoyPhyDrive(CurDrive->PhyDrive, CurDrive->SizeInBytes))
if (IsVentoyPhyDrive(CurDrive->PhyDrive, CurDrive->SizeInBytes, &MBR))
{
GetVentoyVerInPhyDrive(CurDrive, CurDrive->VentoyVersion, sizeof(CurDrive->VentoyVersion));
GetVentoyVerInPhyDrive(CurDrive, &MBR, CurDrive->VentoyVersion, sizeof(CurDrive->VentoyVersion));
}
}
......
......@@ -144,7 +144,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, CHAR *VerBuf, size_t BufLen);
int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, MBR_HEAD *pMBR, CHAR *VerBuf, size_t BufLen);
int Ventoy2DiskInit(void);
int Ventoy2DiskDestroy(void);
PHY_DRIVE_INFO * GetPhyDriveInfoById(int Id);
......@@ -159,5 +159,7 @@ int INIT unxz(unsigned char *in, int in_size,
unsigned char *out, int *in_used,
void(*error)(char *x));
void disk_io_set_param(HANDLE Handle, UINT64 SectorCount);
INT_PTR CALLBACK PartDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
int GetReservedSpaceInMB(void);
#endif
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -104,6 +104,7 @@
<ClCompile Include="ff14\source\ffsystem.c" />
<ClCompile Include="ff14\source\ffunicode.c" />
<ClCompile Include="Language.c" />
<ClCompile Include="PartDialog.c" />
<ClCompile Include="PhyDrive.c" />
<ClCompile Include="Utility.c" />
<ClCompile Include="Ventoy2Disk.c" />
......
......@@ -69,6 +69,9 @@
<ClCompile Include="ff14\source\ffunicode.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="PartDialog.c">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Ventoy2Disk.h">
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment