1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[ext2fs] use physical + offset always for extfs partition creation

This commit is contained in:
Pete Batard 2020-09-10 17:50:06 +01:00
parent 1e56c8812e
commit f04ed61805
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
4 changed files with 31 additions and 11 deletions

View file

@ -406,11 +406,7 @@ char* AltGetLogicalName(DWORD DriveIndex, uint64_t PartitionOffset, BOOL bKeepTr
static_strcpy(volume_name, groot_name);
if (!QueryDosDeviceA(path, &volume_name[groot_len], (DWORD)(MAX_PATH - groot_len)) || (strlen(volume_name) < 20)) {
suprintf("Could not find a DOS volume name for '%s': %s", path, WindowsErrorString());
// If we are on the right drive, we enable a custom access mode through physical + offset
if (!matching_drive)
goto out;
static_sprintf(volume_name, "\\\\.\\PhysicalDrive%lu%s %I64u %I64u", DriveIndex, bKeepTrailingBackslash ? "\\" : "",
SelectedDrive.PartitionOffset[i], SelectedDrive.PartitionSize[i]);
} else if (bKeepTrailingBackslash) {
static_strcat(volume_name, "\\");
}
@ -420,6 +416,29 @@ out:
return ret;
}
/*
* Custom volume name for extfs formatting (that includes partition offset and partition size)
* so that these can be created and accessed on pre 1703 versions of Windows.
*/
char* GetExtPartitionName(DWORD DriveIndex, uint64_t PartitionOffset)
{
DWORD i;
char* ret = NULL, volume_name[MAX_PATH];
// Can't operate if we're not on the selected drive
if (DriveIndex != SelectedDrive.DeviceNumber)
goto out;
CheckDriveIndex(DriveIndex);
for (i = 0; (i < MAX_PARTITIONS) && (PartitionOffset != SelectedDrive.PartitionOffset[i]); i++);
if (i >= MAX_PARTITIONS)
goto out;
static_sprintf(volume_name, "\\\\.\\PhysicalDrive%lu %I64u %I64u", DriveIndex,
SelectedDrive.PartitionOffset[i], SelectedDrive.PartitionSize[i]);
ret = safe_strdup(volume_name);
out:
return ret;
}
/*
* Call on VDS to refresh the drive layout
*/

View file

@ -371,6 +371,7 @@ BOOL DeletePartitions(DWORD DriveIndex);
HANDLE GetPhysicalHandle(DWORD DriveIndex, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWriteShare);
char* GetLogicalName(DWORD DriveIndex, uint64_t PartitionOffset, BOOL bKeepTrailingBackslash, BOOL bSilent);
char* AltGetLogicalName(DWORD DriveIndex, uint64_t PartitionOffset, BOOL bKeepTrailingBackslash, BOOL bSilent);
char* GetExtPartitionName(DWORD DriveIndex, uint64_t PartitionOffset);
BOOL WaitForLogical(DWORD DriveIndex, uint64_t PartitionOffset);
HANDLE GetLogicalHandle(DWORD DriveIndex, uint64_t PartitionOffset, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWriteShare);
int GetDriveNumber(HANDLE hDrive, char* path);

View file

@ -203,7 +203,7 @@ const char* GetExtFsLabel(DWORD DriveIndex, uint64_t PartitionOffset)
errcode_t r;
ext2_filsys ext2fs = NULL;
io_manager manager = nt_io_manager();
char* volume_name = AltGetLogicalName(DriveIndex, PartitionOffset, FALSE, TRUE);
char* volume_name = GetExtPartitionName(DriveIndex, PartitionOffset);
if (volume_name == NULL)
return NULL;
@ -266,7 +266,7 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP
}
CloseHandle(h);
#else
volume_name = AltGetLogicalName(DriveIndex, PartitionOffset, FALSE, TRUE);
volume_name = GetExtPartitionName(DriveIndex, PartitionOffset);
#endif
if ((volume_name == NULL) | (strlen(FSName) != 4) || (strncmp(FSName, "ext", 3) != 0)) {
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_INVALID_PARAMETER;

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.12.1698"
CAPTION "Rufus 3.12.1699"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -395,8 +395,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,12,1698,0
PRODUCTVERSION 3,12,1698,0
FILEVERSION 3,12,1699,0
PRODUCTVERSION 3,12,1699,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -414,13 +414,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.12.1698"
VALUE "FileVersion", "3.12.1699"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.12.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.12.1698"
VALUE "ProductVersion", "3.12.1699"
END
END
BLOCK "VarFileInfo"