[core] allow detection and format of "raw" drives

* eg. GPT drives with no partitions were not enumerated by default
* fixed disk mode needs to be enabled for this detection to occur
* also fix the unwanted use of a drive letter in GetDrivePartitionData
* also add a check for going over MAX_DRIVES
* also fix improper separator line in FreeDOS menu due to UTF-8 source
* closes #124
This commit is contained in:
Pete Batard 2013-02-10 21:54:47 +00:00
parent a16d35698f
commit 63e6c02f02
6 changed files with 143 additions and 30 deletions

View file

@ -60,6 +60,7 @@ HANDLE GetDriveHandle(DWORD DriveIndex, char* DriveLetter, BOOL bWriteAccess, BO
char logical_drive[] = "\\\\.\\#:";
char physical_drive[24];
DriveIndex &= DRIVE_INDEX_MASK;
if ((DriveIndex < DRIVE_INDEX_MIN) || (DriveIndex > DRIVE_INDEX_MAX)) {
uprintf("WARNING: Bad index value. Please check the code!\n");
}
@ -160,8 +161,10 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label)
*label = STR_NO_LABEL;
hDrive = GetDriveHandle(DriveIndex, letter, FALSE, FALSE);
if (hDrive == INVALID_HANDLE_VALUE)
return FALSE;
if (hDrive == INVALID_HANDLE_VALUE) {
// Assume we have a raw drive without volume assigned if enable_fixed_disk is true
return enable_fixed_disks;
}
safe_closehandle(hDrive);
AutorunPath[0] = *letter;
wDrivePath[0] = *letter;
@ -206,7 +209,7 @@ BOOL GetDrivePartitionData(DWORD DeviceNumber, char* FileSystemName, DWORD FileS
char DrivePath[] = "#:\\", tmp[256];
DWORD i, nb_partitions = 0;
hDrive = GetDriveHandle(DeviceNumber, DrivePath, FALSE, FALSE);
hDrive = GetDriveHandle(DeviceNumber, NULL, FALSE, FALSE);
if (hDrive == INVALID_HANDLE_VALUE)
return FALSE;