mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[core] reinstate locking of the logical drive when writing images
* When writing images such as tails, that contain a large ESP, Windows forcibly removes the media while we are writing it, unless we lock the logical drive. * Also fix a Bled Coverity warning.
This commit is contained in:
		
							parent
							
								
									69bf32dd33
								
							
						
					
					
						commit
						65a0c2c42d
					
				
					 4 changed files with 30 additions and 9 deletions
				
			
		|  | @ -1214,13 +1214,18 @@ unpack_gz_stream(transformer_state_t *xstate) | ||||||
| 	total = 0; | 	total = 0; | ||||||
| 
 | 
 | ||||||
| 	ALLOC_STATE; | 	ALLOC_STATE; | ||||||
| 	if (state == NULL) | 	if (state == NULL) { | ||||||
|  | 		bb_error_msg("alloc error"); | ||||||
| 		return -1; | 		return -1; | ||||||
|  | 	} | ||||||
| 	to_read = -1; | 	to_read = -1; | ||||||
| //	bytebuffer_max = 0x8000;
 | //	bytebuffer_max = 0x8000;
 | ||||||
| 	bytebuffer = xmalloc(bytebuffer_max); | 	bytebuffer = xmalloc(bytebuffer_max); | ||||||
| 	if (bytebuffer == NULL) | 	if (bytebuffer == NULL) { | ||||||
| 		return -1; | 		bb_error_msg("alloc error"); | ||||||
|  | 		total = -1; | ||||||
|  | 		goto ret; | ||||||
|  | 	} | ||||||
| 	gunzip_src_fd = xstate->src_fd; | 	gunzip_src_fd = xstate->src_fd; | ||||||
| 
 | 
 | ||||||
|  again: |  again: | ||||||
|  |  | ||||||
|  | @ -1099,7 +1099,6 @@ UINT GetDriveTypeFromIndex(DWORD DriveIndex) | ||||||
| 	return drive_type; | 	return drive_type; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| // Removes all drive letters associated with the specific drive, and return
 | // Removes all drive letters associated with the specific drive, and return
 | ||||||
| // either the first or last letter that was removed, according to bReturnLast.
 | // either the first or last letter that was removed, according to bReturnLast.
 | ||||||
| char RemoveDriveLetters(DWORD DriveIndex, BOOL bReturnLast, BOOL bSilent) | char RemoveDriveLetters(DWORD DriveIndex, BOOL bReturnLast, BOOL bSilent) | ||||||
|  |  | ||||||
							
								
								
									
										17
									
								
								src/format.c
									
										
									
									
									
								
							
							
						
						
									
										17
									
								
								src/format.c
									
										
									
									
									
								
							|  | @ -1746,6 +1746,23 @@ DWORD WINAPI FormatThread(void* param) | ||||||
| 		goto out; | 		goto out; | ||||||
| 	} | 	} | ||||||
| 	RefreshDriveLayout(hPhysicalDrive); | 	RefreshDriveLayout(hPhysicalDrive); | ||||||
|  | 
 | ||||||
|  | 	// If we write an image that contains an ESP, Windows forcibly reassigns/removes the target
 | ||||||
|  | 	// drive, which causes a write error. To work around this, we must lock the logical drive.
 | ||||||
|  | 	if ((boot_type == BT_IMAGE) && write_as_image) { | ||||||
|  | 		// ...and get a lock to the logical drive so that we can actually write something
 | ||||||
|  | 		hLogicalVolume = GetLogicalHandle(DriveIndex, 0, TRUE, FALSE, !actual_lock_drive); | ||||||
|  | 		if (hLogicalVolume == INVALID_HANDLE_VALUE) { | ||||||
|  | 			uprintf("Could not lock volume"); | ||||||
|  | 			FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED; | ||||||
|  | 			goto out; | ||||||
|  | 		} else if (hLogicalVolume == NULL) { | ||||||
|  | 			// NULL is returned for cases where the drive is not yet partitioned
 | ||||||
|  | 			uprintf("Drive does not appear to be partitioned"); | ||||||
|  | 		} else if (!UnmountVolume(hLogicalVolume)) { | ||||||
|  | 			uprintf("Trying to continue regardless..."); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| 	CHECK_FOR_USER_CANCEL; | 	CHECK_FOR_USER_CANCEL; | ||||||
| 
 | 
 | ||||||
| 	if (!zero_drive && !write_as_image) { | 	if (!zero_drive && !write_as_image) { | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 232, 326 | IDD_DIALOG DIALOGEX 12, 12, 232, 326 | ||||||
| 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 3.13.1716" | CAPTION "Rufus 3.13.1717" | ||||||
| FONT 9, "Segoe UI Symbol", 400, 0, 0x0 | FONT 9, "Segoe UI Symbol", 400, 0, 0x0 | ||||||
| BEGIN | BEGIN | ||||||
|     LTEXT           "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP |     LTEXT           "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP | ||||||
|  | @ -395,8 +395,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 3,13,1716,0 |  FILEVERSION 3,13,1717,0 | ||||||
|  PRODUCTVERSION 3,13,1716,0 |  PRODUCTVERSION 3,13,1717,0 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -414,13 +414,13 @@ BEGIN | ||||||
|             VALUE "Comments", "https://rufus.ie" |             VALUE "Comments", "https://rufus.ie" | ||||||
|             VALUE "CompanyName", "Akeo Consulting" |             VALUE "CompanyName", "Akeo Consulting" | ||||||
|             VALUE "FileDescription", "Rufus" |             VALUE "FileDescription", "Rufus" | ||||||
|             VALUE "FileVersion", "3.13.1716" |             VALUE "FileVersion", "3.13.1717" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)" | ||||||
|             VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" |             VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" | ||||||
|             VALUE "OriginalFilename", "rufus-3.13.exe" |             VALUE "OriginalFilename", "rufus-3.13.exe" | ||||||
|             VALUE "ProductName", "Rufus" |             VALUE "ProductName", "Rufus" | ||||||
|             VALUE "ProductVersion", "3.13.1716" |             VALUE "ProductVersion", "3.13.1717" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue