mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[core] fix handling of BFD drives
* A BFD (Big Floppy Disk) is a disk that isn't actually partitioned, but where the first data sector starts at sector 0 * Closes #814
This commit is contained in:
		
							parent
							
								
									2b0cc9349f
								
							
						
					
					
						commit
						d9a928f5bc
					
				
					 3 changed files with 25 additions and 15 deletions
				
			
		
							
								
								
									
										26
									
								
								src/drive.c
									
										
									
									
									
								
							
							
						
						
									
										26
									
								
								src/drive.c
									
										
									
									
									
								
							|  | @ -664,7 +664,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys | ||||||
| 	PDRIVE_LAYOUT_INFORMATION_EX DriveLayout = (PDRIVE_LAYOUT_INFORMATION_EX)(void*)layout; | 	PDRIVE_LAYOUT_INFORMATION_EX DriveLayout = (PDRIVE_LAYOUT_INFORMATION_EX)(void*)layout; | ||||||
| 	char* volume_name; | 	char* volume_name; | ||||||
| 	char tmp[256]; | 	char tmp[256]; | ||||||
| 	DWORD i, j; | 	DWORD i, j, big_floppy = FALSE; | ||||||
| 
 | 
 | ||||||
| 	if (FileSystemName == NULL) | 	if (FileSystemName == NULL) | ||||||
| 		return FALSE; | 		return FALSE; | ||||||
|  | @ -725,16 +725,23 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys | ||||||
| 				SelectedDrive.nPartitions++; | 				SelectedDrive.nPartitions++; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		suprintf("Partition type: MBR, NB Partitions: %d\n", SelectedDrive.nPartitions); | 		// Detect drives that are using the whole disk as a single partition
 | ||||||
| 		SelectedDrive.has_mbr_uefi_marker = (DriveLayout->Mbr.Signature == MBR_UEFI_MARKER); | 		if ((DriveLayout->PartitionEntry[0].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) && | ||||||
| 		suprintf("Disk ID: 0x%08X %s\n", DriveLayout->Mbr.Signature, SelectedDrive.has_mbr_uefi_marker?"(UEFI target)":""); | 			(DriveLayout->PartitionEntry[0].StartingOffset.QuadPart == 0LL)) { | ||||||
| 		AnalyzeMBR(hPhysical, "Drive"); | 			suprintf("Partition type: BFD (Big Floppy Disk)"); | ||||||
|  | 			big_floppy = TRUE; | ||||||
|  | 		} else { | ||||||
|  | 			suprintf("Partition type: MBR, NB Partitions: %d\n", SelectedDrive.nPartitions); | ||||||
|  | 			SelectedDrive.has_mbr_uefi_marker = (DriveLayout->Mbr.Signature == MBR_UEFI_MARKER); | ||||||
|  | 			suprintf("Disk ID: 0x%08X %s\n", DriveLayout->Mbr.Signature, SelectedDrive.has_mbr_uefi_marker ? "(UEFI target)" : ""); | ||||||
|  | 			AnalyzeMBR(hPhysical, "Drive"); | ||||||
|  | 		} | ||||||
| 		for (i=0; i<DriveLayout->PartitionCount; i++) { | 		for (i=0; i<DriveLayout->PartitionCount; i++) { | ||||||
| 			if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) { | 			if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) { | ||||||
| 				part_type = DriveLayout->PartitionEntry[i].Mbr.PartitionType; | 				part_type = DriveLayout->PartitionEntry[i].Mbr.PartitionType; | ||||||
| 				isUefiNtfs = (i == 1) && (part_type == 0xef) && | 				isUefiNtfs = (i == 1) && (part_type == 0xef) && | ||||||
| 					(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart <= 1*MB); | 					(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart <= 1*MB); | ||||||
| 				suprintf("Partition %d%s:\n", i+1, isUefiNtfs?" (UEFI:NTFS)":""); | 				suprintf("Partition %d%s:\n", i+(big_floppy?0:1), isUefiNtfs?" (UEFI:NTFS)":""); | ||||||
| 				for (j=0; j<ARRAYSIZE(mbr_mountable); j++) { | 				for (j=0; j<ARRAYSIZE(mbr_mountable); j++) { | ||||||
| 					if (part_type == mbr_mountable[j]) { | 					if (part_type == mbr_mountable[j]) { | ||||||
| 						ret = TRUE; | 						ret = TRUE; | ||||||
|  | @ -742,13 +749,12 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				// NB: MinGW's gcc 4.9.2 broke "%lld" printout on XP so we use the inttypes.h "PRI##" qualifiers
 | 				// NB: MinGW's gcc 4.9.2 broke "%lld" printout on XP so we use the inttypes.h "PRI##" qualifiers
 | ||||||
| 				suprintf("  Type: %s (0x%02x)\r\n  Size: %s (%" PRIi64 " bytes)\r\n  Start Sector: %" PRIi64 ", Boot: %s, Recognized: %s\n", | 				suprintf("  Type: %s (0x%02x)\r\n  Size: %s (%" PRIi64 " bytes)\r\n  Start Sector: %" PRIi64 ", Boot: %s", | ||||||
| 					((part_type==0x07)&&(FileSystemName[0]!=0))?FileSystemName:GetPartitionType(part_type), part_type, | 					((part_type==0x07||big_floppy)&&(FileSystemName[0]!=0))?FileSystemName:GetPartitionType(part_type), big_floppy?0:part_type, | ||||||
| 					SizeToHumanReadable(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart, TRUE, FALSE), | 					SizeToHumanReadable(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart, TRUE, FALSE), | ||||||
| 					DriveLayout->PartitionEntry[i].PartitionLength.QuadPart, | 					DriveLayout->PartitionEntry[i].PartitionLength.QuadPart, | ||||||
| 					DriveLayout->PartitionEntry[i].StartingOffset.QuadPart / SelectedDrive.SectorSize, | 					DriveLayout->PartitionEntry[i].StartingOffset.QuadPart / SelectedDrive.SectorSize, | ||||||
| 					DriveLayout->PartitionEntry[i].Mbr.BootIndicator?"Yes":"No", | 					DriveLayout->PartitionEntry[i].Mbr.BootIndicator?"Yes":"No"); | ||||||
| 					DriveLayout->PartitionEntry[i].Mbr.RecognizedPartition?"Yes":"No"); |  | ||||||
| 				SelectedDrive.FirstDataSector = min(SelectedDrive.FirstDataSector, | 				SelectedDrive.FirstDataSector = min(SelectedDrive.FirstDataSector, | ||||||
| 					(DWORD)(DriveLayout->PartitionEntry[i].StartingOffset.QuadPart / SelectedDrive.SectorSize)); | 					(DWORD)(DriveLayout->PartitionEntry[i].StartingOffset.QuadPart / SelectedDrive.SectorSize)); | ||||||
| 				if ((part_type == RUFUS_EXTRA_PARTITION_TYPE) || (isUefiNtfs)) | 				if ((part_type == RUFUS_EXTRA_PARTITION_TYPE) || (isUefiNtfs)) | ||||||
|  |  | ||||||
|  | @ -826,6 +826,10 @@ static BOOL ClearMBRGPT(HANDLE hPhysicalDrive, LONGLONG DiskSize, DWORD SectorSi | ||||||
| 	// with GPT drives that contain a lot of small partitions) we try not not to clear
 | 	// with GPT drives that contain a lot of small partitions) we try not not to clear
 | ||||||
| 	// sectors further than the lowest partition already residing on the disk.
 | 	// sectors further than the lowest partition already residing on the disk.
 | ||||||
| 	num_sectors_to_clear = min(SelectedDrive.FirstDataSector, (DWORD)((add1MB ? 2048 : 0) + MAX_SECTORS_TO_CLEAR)); | 	num_sectors_to_clear = min(SelectedDrive.FirstDataSector, (DWORD)((add1MB ? 2048 : 0) + MAX_SECTORS_TO_CLEAR)); | ||||||
|  | 	// Special case for big floppy disks (FirstDataSector = 0)
 | ||||||
|  | 	if (num_sectors_to_clear < 4) | ||||||
|  | 		num_sectors_to_clear = (DWORD)((add1MB ? 2048 : 0) + MAX_SECTORS_TO_CLEAR); | ||||||
|  | 
 | ||||||
| 	uprintf("Erasing %d sectors", num_sectors_to_clear); | 	uprintf("Erasing %d sectors", num_sectors_to_clear); | ||||||
| 	for (i=0; i<num_sectors_to_clear; i++) { | 	for (i=0; i<num_sectors_to_clear; i++) { | ||||||
| 		if ((IS_ERROR(FormatStatus)) || (write_sectors(hPhysicalDrive, SectorSize, i, 1, pBuf) != SectorSize)) { | 		if ((IS_ERROR(FormatStatus)) || (write_sectors(hPhysicalDrive, SectorSize, i, 1, pBuf) != SectorSize)) { | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 242, 376 | IDD_DIALOG DIALOGEX 12, 12, 242, 376 | ||||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||||
| EXSTYLE WS_EX_ACCEPTFILES | EXSTYLE WS_EX_ACCEPTFILES | ||||||
| CAPTION "Rufus 2.11.987" | CAPTION "Rufus 2.11.988" | ||||||
| FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | ||||||
| BEGIN | BEGIN | ||||||
|     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 |     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 | ||||||
|  | @ -320,8 +320,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 2,11,987,0 |  FILEVERSION 2,11,988,0 | ||||||
|  PRODUCTVERSION 2,11,987,0 |  PRODUCTVERSION 2,11,988,0 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -338,13 +338,13 @@ BEGIN | ||||||
|         BEGIN |         BEGIN | ||||||
|             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" |             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" | ||||||
|             VALUE "FileDescription", "Rufus" |             VALUE "FileDescription", "Rufus" | ||||||
|             VALUE "FileVersion", "2.11.987" |             VALUE "FileVersion", "2.11.988" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" | ||||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" |             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||||
|             VALUE "OriginalFilename", "rufus.exe" |             VALUE "OriginalFilename", "rufus.exe" | ||||||
|             VALUE "ProductName", "Rufus" |             VALUE "ProductName", "Rufus" | ||||||
|             VALUE "ProductVersion", "2.11.987" |             VALUE "ProductVersion", "2.11.988" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue