diff --git a/IMG/cpio/ventoy/hook/debian/antix-disk.sh b/IMG/cpio/ventoy/hook/debian/antix-disk.sh index fc11c53b..e515fd28 100644 --- a/IMG/cpio/ventoy/hook/debian/antix-disk.sh +++ b/IMG/cpio/ventoy/hook/debian/antix-disk.sh @@ -40,13 +40,13 @@ ventoy_os_install_dmsetup_by_unsquashfs() { dmModPath="/usr/lib/modules/$vtKerVer/kernel/drivers/md/dm-mod.$vtKoPo" echo $dmModPath > $VTOY_PATH/fsextract - vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk + vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk 2>>$VTLOG if ! [ -e $VTOY_PATH/sqfs${dmModPath} ]; then rm -rf $VTOY_PATH/sqfs dmModPath="/lib/modules/$vtKerVer/kernel/drivers/md/dm-mod.$vtKoPo" echo $dmModPath > $VTOY_PATH/fsextract - vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk + vtoy_unsquashfs -d $VTOY_PATH/sqfs -n -q -e $VTOY_PATH/fsextract $VTOY_PATH/fsdisk 2>>$VTLOG fi if [ -e $VTOY_PATH/sqfs${dmModPath} ]; then diff --git a/INSTALL/Ventoy2Disk.exe b/INSTALL/Ventoy2Disk.exe index 29154563..aa91ecf7 100644 Binary files a/INSTALL/Ventoy2Disk.exe and b/INSTALL/Ventoy2Disk.exe differ diff --git a/INSTALL/Ventoy2Disk_ARM.exe b/INSTALL/Ventoy2Disk_ARM.exe index f027ec99..9acbd964 100644 Binary files a/INSTALL/Ventoy2Disk_ARM.exe and b/INSTALL/Ventoy2Disk_ARM.exe differ diff --git a/INSTALL/Ventoy2Disk_ARM64.exe b/INSTALL/Ventoy2Disk_ARM64.exe index 47d324ba..c53d0e01 100644 Binary files a/INSTALL/Ventoy2Disk_ARM64.exe and b/INSTALL/Ventoy2Disk_ARM64.exe differ diff --git a/INSTALL/Ventoy2Disk_X64.exe b/INSTALL/Ventoy2Disk_X64.exe index f4f1c176..155e465a 100644 Binary files a/INSTALL/Ventoy2Disk_X64.exe and b/INSTALL/Ventoy2Disk_X64.exe differ diff --git a/Ventoy2Disk/Ventoy2Disk/PartDialog.c b/Ventoy2Disk/Ventoy2Disk/PartDialog.c index eb4aa0d9..317b6b75 100644 Binary files a/Ventoy2Disk/Ventoy2Disk/PartDialog.c and b/Ventoy2Disk/Ventoy2Disk/PartDialog.c differ diff --git a/Ventoy2Disk/Ventoy2Disk/PhyDrive.c b/Ventoy2Disk/Ventoy2Disk/PhyDrive.c index c0cc8063..d64916e5 100644 --- a/Ventoy2Disk/Ventoy2Disk/PhyDrive.c +++ b/Ventoy2Disk/Ventoy2Disk/PhyDrive.c @@ -544,6 +544,199 @@ int GetAllPhysicalDriveInfo(PHY_DRIVE_INFO *pDriveList, DWORD *pDriveCount) return 0; } +BOOL VentoyPhydriveMatch(PHY_DRIVE_INFO* pPhyDrive) +{ + BOOL bRet = FALSE; + DWORD dwBytes; + HANDLE Handle = INVALID_HANDLE_VALUE; + CHAR PhyDrive[128]; + GET_LENGTH_INFORMATION LengthInfo; + STORAGE_PROPERTY_QUERY Query; + STORAGE_DESCRIPTOR_HEADER DevDescHeader; + STORAGE_DEVICE_DESCRIPTOR* pDevDesc = NULL; + STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR diskAlignment; + CHAR VendorId[128] = { 0 }; + CHAR ProductId[128] = { 0 }; + CHAR ProductRev[128] = { 0 }; + CHAR SerialNumber[128] = { 0 }; + + + safe_sprintf(PhyDrive, "\\\\.\\PhysicalDrive%d", pPhyDrive->PhyDrive); + Handle = CreateFileA(PhyDrive, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if (Handle == INVALID_HANDLE_VALUE) + { + Log("Create file Handle:%p %s status:%u", Handle, PhyDrive, LASTERR); + return FALSE; + } + + bRet = DeviceIoControl(Handle, + IOCTL_DISK_GET_LENGTH_INFO, NULL, + 0, + &LengthInfo, + sizeof(LengthInfo), + &dwBytes, + NULL); + if (!bRet) + { + Log("DeviceIoControl IOCTL_DISK_GET_LENGTH_INFO failed error:%u", LASTERR); + return FALSE; + } + + if (pPhyDrive->SizeInBytes != (ULONGLONG)LengthInfo.Length.QuadPart) + { + Log("PHYSICALDRIVE%d size not match %llu %llu", pPhyDrive->PhyDrive, (ULONGLONG)LengthInfo.Length.QuadPart, + (ULONGLONG)pPhyDrive->SizeInBytes); + CHECK_CLOSE_HANDLE(Handle); + return FALSE; + } + + Query.PropertyId = StorageDeviceProperty; + Query.QueryType = PropertyStandardQuery; + + bRet = DeviceIoControl(Handle, + IOCTL_STORAGE_QUERY_PROPERTY, + &Query, + sizeof(Query), + &DevDescHeader, + sizeof(STORAGE_DESCRIPTOR_HEADER), + &dwBytes, + NULL); + if (!bRet) + { + Log("DeviceIoControl1 error:%u dwBytes:%u", LASTERR, dwBytes); + CHECK_CLOSE_HANDLE(Handle); + return FALSE; + } + + if (DevDescHeader.Size < sizeof(STORAGE_DEVICE_DESCRIPTOR)) + { + Log("Invalid DevDescHeader.Size:%u", DevDescHeader.Size); + CHECK_CLOSE_HANDLE(Handle); + return FALSE; + } + + pDevDesc = (STORAGE_DEVICE_DESCRIPTOR*)malloc(DevDescHeader.Size); + if (!pDevDesc) + { + Log("failed to malloc error:%u len:%u", LASTERR, DevDescHeader.Size); + CHECK_CLOSE_HANDLE(Handle); + return FALSE; + } + + bRet = DeviceIoControl(Handle, + IOCTL_STORAGE_QUERY_PROPERTY, + &Query, + sizeof(Query), + pDevDesc, + DevDescHeader.Size, + &dwBytes, + NULL); + if (!bRet) + { + Log("DeviceIoControl2 error:%u dwBytes:%u", LASTERR, dwBytes); + free(pDevDesc); + goto out; + } + + + + memset(&Query, 0, sizeof(STORAGE_PROPERTY_QUERY)); + Query.PropertyId = StorageAccessAlignmentProperty; + Query.QueryType = PropertyStandardQuery; + memset(&diskAlignment, 0, sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR)); + + bRet = DeviceIoControl(Handle, + IOCTL_STORAGE_QUERY_PROPERTY, + &Query, + sizeof(STORAGE_PROPERTY_QUERY), + &diskAlignment, + sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR), + &dwBytes, + NULL); + if (!bRet) + { + Log("DeviceIoControl3 error:%u dwBytes:%u", LASTERR, dwBytes); + } + + if (pPhyDrive->DeviceType != pDevDesc->DeviceType || + pPhyDrive->RemovableMedia != pDevDesc->RemovableMedia || + pPhyDrive->BusType != pDevDesc->BusType || + pPhyDrive->BytesPerLogicalSector != diskAlignment.BytesPerLogicalSector || + pPhyDrive->BytesPerPhysicalSector != diskAlignment.BytesPerPhysicalSector + ) + { + Log("Some properties not match DeviceType[%u %u] Removable[%u %u] BusType[%u %u] LogSec[%u %u] PhySec[%u %u]", + pPhyDrive->DeviceType, pDevDesc->DeviceType, + pPhyDrive->RemovableMedia, pDevDesc->RemovableMedia, + pPhyDrive->BusType, pDevDesc->BusType, + pPhyDrive->BytesPerLogicalSector, diskAlignment.BytesPerLogicalSector, + pPhyDrive->BytesPerPhysicalSector, diskAlignment.BytesPerPhysicalSector + ); + goto out; + } + + if (pDevDesc->VendorIdOffset) + { + safe_strcpy(VendorId, (char*)pDevDesc + pDevDesc->VendorIdOffset); + TrimString(VendorId); + + if (strcmp(pPhyDrive->VendorId, VendorId)) + { + Log("VendorId not match <%s %s>", pPhyDrive->VendorId, VendorId); + goto out; + } + } + + if (pDevDesc->ProductIdOffset) + { + safe_strcpy(ProductId, (char*)pDevDesc + pDevDesc->ProductIdOffset); + TrimString(ProductId); + + if (strcmp(pPhyDrive->ProductId, ProductId)) + { + Log("ProductId not match <%s %s>", pPhyDrive->ProductId, ProductId); + goto out; + } + } + + if (pDevDesc->ProductRevisionOffset) + { + safe_strcpy(ProductRev, (char*)pDevDesc + pDevDesc->ProductRevisionOffset); + TrimString(ProductRev); + + if (strcmp(pPhyDrive->ProductRev, ProductRev)) + { + Log("ProductRev not match <%s %s>", pPhyDrive->ProductRev, ProductRev); + goto out; + } + } + + if (pDevDesc->SerialNumberOffset) + { + safe_strcpy(SerialNumber, (char*)pDevDesc + pDevDesc->SerialNumberOffset); + TrimString(SerialNumber); + + if (strcmp(pPhyDrive->SerialNumber, SerialNumber)) + { + Log("ProductRev not match <%s %s>", pPhyDrive->SerialNumber, SerialNumber); + goto out; + } + } + + Log("PhyDrive%d ALL match, now continue", pPhyDrive->PhyDrive); + + bRet = TRUE; + +out: + if (pDevDesc) + { + free(pDevDesc); + } + + CHECK_CLOSE_HANDLE(Handle); + + return bRet; +} static HANDLE g_FatPhyDrive; static UINT64 g_Part2StartSec; diff --git a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h index b0947256..6106520d 100644 --- a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h +++ b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h @@ -253,6 +253,7 @@ int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo); BOOL IsVentoyLogicalDrive(CHAR DriveLetter); int GetRegDwordValue(HKEY Key, LPCSTR SubKey, LPCSTR ValueName, DWORD *pValue); int GetPhysicalDriveCount(void); +BOOL VentoyPhydriveMatch(PHY_DRIVE_INFO* pPhyDrive); int GetAllPhysicalDriveInfo(PHY_DRIVE_INFO *pDriveList, DWORD *pDriveCount); int GetPhyDriveByLogicalDrive(int DriveLetter, UINT64*Offset); int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, UINT64 Part2StartSector, CHAR *VerBuf, size_t BufLen, BOOL *pSecureBoot); @@ -388,4 +389,11 @@ PHY_DRIVE_INFO* CLI_PhyDrvInfo(void); #define VTSI_SUPPORT 1 +#define WM_OFFSET (WM_USER + 40) +#define WM_WIDTH_CHANGE (WM_OFFSET + 1) + + +int ExpandDlg(HWND hParent, UINT uiID, int WidthDelta); +int MoveDlg(HWND hParent, UINT uiID, int WidthDelta); + #endif diff --git a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc index 67f685fc..0bbba211 100644 Binary files a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc and b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc differ diff --git a/Ventoy2Disk/Ventoy2Disk/WinDialog.c b/Ventoy2Disk/Ventoy2Disk/WinDialog.c index cfebec9c..388b7b03 100644 Binary files a/Ventoy2Disk/Ventoy2Disk/WinDialog.c and b/Ventoy2Disk/Ventoy2Disk/WinDialog.c differ diff --git a/Ventoy2Disk/Ventoy2Disk/resource.h b/Ventoy2Disk/Ventoy2Disk/resource.h index 32ec0093..58e198fa 100644 Binary files a/Ventoy2Disk/Ventoy2Disk/resource.h and b/Ventoy2Disk/Ventoy2Disk/resource.h differ