Skip to content

Commit

Permalink
Support drag resize dialog window width.
Browse files Browse the repository at this point in the history
  • Loading branch information
ventoy committed Aug 22, 2023
1 parent d0e10f8 commit 2fee243
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 2 deletions.
4 changes: 2 additions & 2 deletions IMG/cpio/ventoy/hook/debian/antix-disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified INSTALL/Ventoy2Disk.exe
Binary file not shown.
Binary file modified INSTALL/Ventoy2Disk_ARM.exe
Binary file not shown.
Binary file modified INSTALL/Ventoy2Disk_ARM64.exe
Binary file not shown.
Binary file modified INSTALL/Ventoy2Disk_X64.exe
Binary file not shown.
Binary file modified Ventoy2Disk/Ventoy2Disk/PartDialog.c
Binary file not shown.
193 changes: 193 additions & 0 deletions Ventoy2Disk/Ventoy2Disk/PhyDrive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Binary file modified Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc
Binary file not shown.
Binary file modified Ventoy2Disk/Ventoy2Disk/WinDialog.c
Binary file not shown.
Binary file modified Ventoy2Disk/Ventoy2Disk/resource.h
Binary file not shown.

0 comments on commit 2fee243

Please sign in to comment.