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; | ||||
| 	char* volume_name; | ||||
| 	char tmp[256]; | ||||
| 	DWORD i, j; | ||||
| 	DWORD i, j, big_floppy = FALSE; | ||||
| 
 | ||||
| 	if (FileSystemName == NULL) | ||||
| 		return FALSE; | ||||
|  | @ -725,16 +725,23 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys | |||
| 				SelectedDrive.nPartitions++; | ||||
| 			} | ||||
| 		} | ||||
| 		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"); | ||||
| 		// Detect drives that are using the whole disk as a single partition
 | ||||
| 		if ((DriveLayout->PartitionEntry[0].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) && | ||||
| 			(DriveLayout->PartitionEntry[0].StartingOffset.QuadPart == 0LL)) { | ||||
| 			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++) { | ||||
| 			if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) { | ||||
| 				part_type = DriveLayout->PartitionEntry[i].Mbr.PartitionType; | ||||
| 				isUefiNtfs = (i == 1) && (part_type == 0xef) && | ||||
| 					(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++) { | ||||
| 					if (part_type == mbr_mountable[j]) { | ||||
| 						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
 | ||||
| 				suprintf("  Type: %s (0x%02x)\r\n  Size: %s (%" PRIi64 " bytes)\r\n  Start Sector: %" PRIi64 ", Boot: %s, Recognized: %s\n", | ||||
| 					((part_type==0x07)&&(FileSystemName[0]!=0))?FileSystemName:GetPartitionType(part_type), part_type, | ||||
| 				suprintf("  Type: %s (0x%02x)\r\n  Size: %s (%" PRIi64 " bytes)\r\n  Start Sector: %" PRIi64 ", Boot: %s", | ||||
| 					((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), | ||||
| 					DriveLayout->PartitionEntry[i].PartitionLength.QuadPart, | ||||
| 					DriveLayout->PartitionEntry[i].StartingOffset.QuadPart / SelectedDrive.SectorSize, | ||||
| 					DriveLayout->PartitionEntry[i].Mbr.BootIndicator?"Yes":"No", | ||||
| 					DriveLayout->PartitionEntry[i].Mbr.RecognizedPartition?"Yes":"No"); | ||||
| 					DriveLayout->PartitionEntry[i].Mbr.BootIndicator?"Yes":"No"); | ||||
| 				SelectedDrive.FirstDataSector = min(SelectedDrive.FirstDataSector, | ||||
| 					(DWORD)(DriveLayout->PartitionEntry[i].StartingOffset.QuadPart / SelectedDrive.SectorSize)); | ||||
| 				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
 | ||||
| 	// 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)); | ||||
| 	// 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); | ||||
| 	for (i=0; i<num_sectors_to_clear; i++) { | ||||
| 		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 | ||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||
| EXSTYLE WS_EX_ACCEPTFILES | ||||
| CAPTION "Rufus 2.11.987" | ||||
| CAPTION "Rufus 2.11.988" | ||||
| FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | ||||
| BEGIN | ||||
|     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 | ||||
|  | @ -320,8 +320,8 @@ END | |||
| // | ||||
| 
 | ||||
| VS_VERSION_INFO VERSIONINFO | ||||
|  FILEVERSION 2,11,987,0 | ||||
|  PRODUCTVERSION 2,11,987,0 | ||||
|  FILEVERSION 2,11,988,0 | ||||
|  PRODUCTVERSION 2,11,988,0 | ||||
|  FILEFLAGSMASK 0x3fL | ||||
| #ifdef _DEBUG | ||||
|  FILEFLAGS 0x1L | ||||
|  | @ -338,13 +338,13 @@ BEGIN | |||
|         BEGIN | ||||
|             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" | ||||
|             VALUE "FileDescription", "Rufus" | ||||
|             VALUE "FileVersion", "2.11.987" | ||||
|             VALUE "FileVersion", "2.11.988" | ||||
|             VALUE "InternalName", "Rufus" | ||||
|             VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" | ||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||
|             VALUE "OriginalFilename", "rufus.exe" | ||||
|             VALUE "ProductName", "Rufus" | ||||
|             VALUE "ProductVersion", "2.11.987" | ||||
|             VALUE "ProductVersion", "2.11.988" | ||||
|         END | ||||
|     END | ||||
|     BLOCK "VarFileInfo" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue